ZQuest Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2024-05-02 03:25:59
Exec Total Coverage
Lines: 1997 4415 45.2%
Functions: 137 331 41.4%
Branches: 1322 3590 36.8%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/render.h"
6 #include "zalleg/zalleg.h"
7 #include "base/qrs.h"
8 #include "base/dmap.h"
9 #include <functional>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <cstring>
13 #include <math.h>
14 #include <map>
15 #include <filesystem>
16 #include <ctype.h>
17 #include <sstream>
18 #include "base/version.h"
19 #include "base/zc_alleg.h"
20 #include "gamedata.h"
21 #include "zc/zc_init.h"
22 #include "init.h"
23 #include "zc/replay.h"
24 #include "zc/cheats.h"
25 #include "zc/render.h"
26 #include "base/zc_math.h"
27 #include "base/zapp.h"
28 #include "dialog/cheatkeys.h"
29 #include "metadata/metadata.h"
30 #include "zc/zelda.h"
31 #include "zc/saves.h"
32 #include "tiles.h"
33 #include "base/colors.h"
34 #include "pal.h"
35 #include "base/zsys.h"
36 #include "qst.h"
37 #include "zc/zc_sys.h"
38 #include "play_midi.h"
39 #include "gui/jwin_a5.h"
40 #include "base/jwinfsel.h"
41 #include "base/gui.h"
42 #include "midi.h"
43 #include "subscr.h"
44 #include "zc/maps.h"
45 #include "sprite.h"
46 #include "zc/guys.h"
47 #include "zc/hero.h"
48 #include "zc/title.h"
49 #include "particles.h"
50 #include "sound/zcmusic.h"
51 #include "zconsole.h"
52 #include "zc/ffscript.h"
53 #include "dialog/info.h"
54 #include "dialog/alert.h"
55 #include "zc/combos.h"
56 #include "zc/jit.h"
57 #include "zc/zc_subscr.h"
58 #include <fmt/format.h>
59 #include "zinfo.h"
60 #include "base/misctypes.h"
61 #include "music_playback.h"
62 #include <base/new_menu.h>
63
64 #ifdef __EMSCRIPTEN__
65 #include "base/emscripten_utils.h"
66 #endif
67
68 using namespace std::chrono_literals;
69
70 extern FFScript FFCore;
71 extern bool Playing;
72 int32_t sfx_voice[WAV_COUNT];
73 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
74 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
75
76 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
77 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
78
79 extern byte monochrome_console;
80
81 extern HeroClass Hero;
82 extern zcmodule moduledata;
83 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
84 extern particle_list particles;
85 extern int32_t loadlast;
86 extern char *sfx_string[WAV_COUNT];
87 byte use_dwm_flush;
88 byte use_save_indicator;
89 int32_t paused_midi_pos = 0;
90 byte midi_suspended = 0;
91 byte zc_192b163_warp_compatibility;
92 char modulepath[2048];
93 bool epilepsyFlashReduction;
94 signed char pause_in_background_menu_init = 0;
95 byte pause_in_background = 0;
96 bool is_sys_pal = false;
97 static bool load_control_called_this_frame;
98 extern PALETTE* hw_palette;
99 extern bool update_hw_pal;
100 extern const char* dmaplist(int32_t index, int32_t* list_size);
101 int32_t getnumber(const char *prompt,int32_t initialval);
102
103 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
104 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
105
106 static const char *qst_module_name = "current_module";
107 #ifdef ALLEGRO_LINUX
108 static const char *samplepath = "samplesoundset/patches.dat";
109 #endif
110 char qst_files_path[2048];
111
112 extern TopMenu the_player_menu;
113 #ifdef _MSC_VER
114 #define getcwd _getcwd
115 #endif
116
117 bool rF11();
118 bool rI();
119 bool rQ();
120 bool zc_key_pressed();
121
122 #ifdef _WIN32
123
124 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
125 extern "C"
126 {
127 typedef HRESULT(WINAPI *t_DwmFlush)();
128 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
129 }
130
131 void do_DwmFlush()
132 {
133 static HMODULE shell = LoadLibrary("dwmapi.dll");
134
135 if(!shell)
136 return;
137
138 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
139 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
140
141 BOOL enabled;
142 isEnabled(&enabled);
143
144 if(isEnabled)
145 flush();
146 }
147
148 #endif // _WIN32
149
150 92829 bool flash_reduction_enabled(bool check_qr)
151 {
152
4/4
✓ Branch 0 taken 88404 times.
✓ Branch 1 taken 4425 times.
✓ Branch 2 taken 87576 times.
✓ Branch 3 taken 92001 times.
92829 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
153 }
154
155 // Dialogue largening
156 void large_dialog(DIALOG *d)
157 {
158 large_dialog(d, 1.5);
159 }
160
161 void large_dialog(DIALOG *d, float RESIZE_AMT)
162 {
163 if(!d[0].d1)
164 {
165 d[0].d1 = 1;
166 int32_t oldwidth = d[0].w;
167 int32_t oldheight = d[0].h;
168 int32_t oldx = d[0].x;
169 int32_t oldy = d[0].y;
170 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
171 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
172 d[0].w = int32_t(d[0].w*RESIZE_AMT);
173 d[0].h = int32_t(d[0].h*RESIZE_AMT);
174
175 for(int32_t i=1; d[i].proc !=NULL; i++)
176 {
177 // Place elements horizontally
178 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
179 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
180
181 if(d[i].proc != d_stringloader)
182 {
183 if(d[i].proc==d_bitmap_proc)
184 {
185 d[i].w *= 2;
186 }
187 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
188 }
189
190 // Place elements vertically
191 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
192 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
193
194 // Vertically resize elements
195 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
196 {
197 d[i].h = int32_t((double)d[i].h*1.5);
198 }
199 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
200 {
201 d[i].y += int32_t((double)d[i].h*0.25);
202 d[i].h = int32_t((double)d[i].h*1.25);
203 }
204 else if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].h *= 2;
207 }
208 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
209
210 // Fix frames
211 if(d[i].proc == jwin_frame_proc)
212 {
213 d[i].x++;
214 d[i].y++;
215 d[i].w-=4;
216 d[i].h-=4;
217 }
218 }
219 }
220
221 for(int32_t i=1; d[i].proc!=NULL; i++)
222 {
223 if(d[i].proc==jwin_slider_proc)
224 continue;
225
226 // Bigger font
227 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
228
229 if(!d[i].dp2 && bigfontproc)
230 {
231 d[i].dp2 = get_zc_font(font_lfont_l);
232 }
233 else if(!bigfontproc)
234 {
235 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
236 }
237
238 // Make checkboxes work
239 if(d[i].proc == jwin_check_proc)
240 d[i].proc = jwin_checkfont_proc;
241 else if(d[i].proc == jwin_radio_proc)
242 d[i].proc = jwin_radiofont_proc;
243 }
244
245 jwin_center_dialog(d);
246 }
247
248
249 /**********************************/
250 /******** System functions ********/
251 /**********************************/
252
253 static char cfg_sect[] = "zeldadx"; //We need to rename this.
254 static char ctrl_sect[] = "Controls";
255 static char sfx_sect[] = "Volume";
256
257 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
258 {
259 return D_O_K;
260 }
261
262 bool is_reserved_key(int c)
263 {
264 switch(c)
265 {
266 case KEY_ESC:
267 return true;
268 }
269 return false;
270 }
271 bool is_reserved_keycombo(int c, int modflag)
272 {
273 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
274 return true;
275 return false;
276 }
277 bool checkcheat(Cheat cheat)
278 {
279 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
280 return true; //Main key pressed
281 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
282 return true; //Alt key pressed
283 return false;
284 }
285 262 void load_default_cheatkeys()
286 {
287 262 memset(cheatkeys, 0, sizeof(cheatkeys));
288 262 cheatkeys[Cheat::Life][0] = KEY_H;
289 262 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
290 262 cheatkeys[Cheat::Magic][0] = KEY_M;
291 262 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
292 262 cheatkeys[Cheat::Rupies][0] = KEY_R;
293 262 cheatkeys[Cheat::Bombs][0] = KEY_B;
294 262 cheatkeys[Cheat::Arrows][0] = KEY_A;
295 262 cheatkeys[Cheat::Clock][0] = KEY_I;
296 262 cheatkeys[Cheat::Walls][0] = KEY_F11;
297 262 cheatkeys[Cheat::Fast][0] = KEY_Q;
298 262 cheatkeys[Cheat::Light][0] = KEY_L;
299 262 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
300 262 cheatkeys[Cheat::Kill][0] = KEY_K;
301 262 cheatkeys[Cheat::GoTo][0] = KEY_G;
302 262 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
303 262 cheatkeys[Cheat::ShowL0][0] = KEY_0;
304 262 cheatkeys[Cheat::ShowL1][0] = KEY_1;
305 262 cheatkeys[Cheat::ShowL2][0] = KEY_2;
306 262 cheatkeys[Cheat::ShowL3][0] = KEY_3;
307 262 cheatkeys[Cheat::ShowL4][0] = KEY_4;
308 262 cheatkeys[Cheat::ShowL5][0] = KEY_5;
309 262 cheatkeys[Cheat::ShowL6][0] = KEY_6;
310 262 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
311 262 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
312 262 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
313 262 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
314 262 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
315 262 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
316 262 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
317 262 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
318 262 }
319 262 void load_game_configs()
320 {
321 262 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"modules/classic.zmod"));
322 262 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
323 262 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
324 262 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
325 262 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
326 262 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
327 262 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
328 262 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
329 262 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
330 262 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
331 262 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
332 262 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
333 262 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
334 262 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
335 262 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
336
337 //cheat modifier keya
338 262 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
339 262 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
340 262 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
341 262 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
342
343 //cheat keys
344 262 load_default_cheatkeys();
345 char buf[256];
346
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 9432 times.
9694 for(size_t q = 1; q < Cheat::Last; ++q)
347 {
348
1/2
✓ Branch 0 taken 9432 times.
✗ Branch 1 not taken.
9432 if(!bindable_cheat((Cheat)q)) continue;
349 9432 std::string cheatname = cheat_to_string((Cheat)q);
350
1/2
✓ Branch 0 taken 9432 times.
✗ Branch 1 not taken.
9432 util::lowerstr(cheatname);
351 9432 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
352
1/2
✓ Branch 0 taken 9432 times.
✗ Branch 1 not taken.
9432 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
353 9432 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
354
1/2
✓ Branch 0 taken 9432 times.
✗ Branch 1 not taken.
9432 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
355 9432 }
356
357
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
358 joystick_index = 0;
359
360 262 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
361 262 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
362 262 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
363 262 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
364 262 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
365 262 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
366 262 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
367 262 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
368 262 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
369 262 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
370
371 262 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
372 262 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
373 262 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
374 262 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
375
376 262 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
377 262 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
378 262 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
379 262 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
380 262 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
381 262 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
382 262 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
383 262 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
384 262 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
385 262 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
386 262 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
387
388 262 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
389 262 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
390 262 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
391 262 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
392
393 262 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
394
395 262 midi_volume = zc_get_config(sfx_sect,"midi",255);
396 262 sfx_volume = zc_get_config(sfx_sect,"sfx",255);
397 262 emusic_volume = zc_get_config(sfx_sect,"emusic",255);
398 262 pan_style = zc_get_config(sfx_sect,"pan",1);
399 262 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
400 262 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
401 262 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
402 262 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
403 262 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
404 262 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
405 262 SnapshotScale = zc_get_config(cfg_sect,"snapshot_scale",2);
406 262 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
407 #ifdef __EMSCRIPTEN__
408 if (em_is_mobile()) NameEntryMode = 2;
409 #endif
410 262 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
411 262 ShowGameTime = zc_get_config(cfg_sect,"showtime",0);
412 262 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
413 262 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
414 262 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
415 262 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
416
417 262 window_width = resx = zc_get_config(cfg_sect,"window_width",-1);
418 262 window_height = resy = zc_get_config(cfg_sect,"window_height",-1);
419 262 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
420 262 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
421 262 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
422 262 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
423 262 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
424
425 262 loadlast = zc_get_config(cfg_sect,"load_last",0);
426
427 262 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
428
429 262 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
430 262 info_opacity = zc_get_config("zc","debug_info_opacity",255);
431 #ifdef _WIN32
432 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
433 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
434 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
435 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
436
437 // This one's for Aero
438 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
439
440 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
441 #else //UNIX
442 262 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
443 262 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
444 262 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
445 #endif
446 262 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
447 262 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
448
449 262 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
450 262 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
451 262 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
452 262 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
453 262 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
454 262 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
455 262 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
456 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
457 262 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
458 262 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
459 262 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
460 262 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
461 262 SkipTitle = zc_get_config(cfg_sect,"skip_title",0);
462 262 }
463
464 void save_control_configs(bool kb)
465 {
466 if(kb)
467 {
468 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
469 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
470 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
471 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
472
473 if (!replay_is_replaying())
474 {
475 zc_set_config(ctrl_sect,"key_a",Akey);
476 zc_set_config(ctrl_sect,"key_b",Bkey);
477 zc_set_config(ctrl_sect,"key_s",Skey);
478 zc_set_config(ctrl_sect,"key_l",Lkey);
479 zc_set_config(ctrl_sect,"key_r",Rkey);
480 zc_set_config(ctrl_sect,"key_p",Pkey);
481 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
482 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
483 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
484 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
485 zc_set_config(ctrl_sect,"key_up", DUkey);
486 zc_set_config(ctrl_sect,"key_down", DDkey);
487 zc_set_config(ctrl_sect,"key_left", DLkey);
488 zc_set_config(ctrl_sect,"key_right",DRkey);
489 }
490 }
491 else
492 {
493 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
494 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
495 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
496 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
497 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
498 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
499 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
500 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
501 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
502 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
503 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
504 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
505 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
506 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
507
508 zc_set_config(ctrl_sect,"btn_a",Abtn);
509 zc_set_config(ctrl_sect,"btn_b",Bbtn);
510 zc_set_config(ctrl_sect,"btn_s",Sbtn);
511 zc_set_config(ctrl_sect,"btn_m",Mbtn);
512 zc_set_config(ctrl_sect,"btn_l",Lbtn);
513 zc_set_config(ctrl_sect,"btn_r",Rbtn);
514 zc_set_config(ctrl_sect,"btn_p",Pbtn);
515 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
516 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
517 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
518 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
519
520 zc_set_config(ctrl_sect,"btn_up",DUbtn);
521 zc_set_config(ctrl_sect,"btn_down",DDbtn);
522 zc_set_config(ctrl_sect,"btn_left",DLbtn);
523 zc_set_config(ctrl_sect,"btn_right",DRbtn);
524 }
525 }
526
527 void save_cheatkeys()
528 {
529 char buf[256];
530 for(size_t q = 1; q < Cheat::Last; ++q)
531 {
532 if(!bindable_cheat((Cheat)q)) continue;
533 std::string cheatname = cheat_to_string((Cheat)q);
534 util::lowerstr(cheatname);
535 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
536 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
537 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
538 if(cheatkeys[q][1])
539 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
540 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
541 }
542 }
543
544 void save_game_configs()
545 {
546 packfile_password("");
547
548 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
549
550 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
551 {
552 int o_window_x, o_window_y;
553 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
554 zc_set_config(cfg_sect,"window_x",o_window_x);
555 zc_set_config(cfg_sect,"window_y",o_window_y);
556 }
557
558 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
559 {
560 window_width = al_get_display_width(all_get_display());
561 window_height = al_get_display_height(all_get_display());
562 zc_set_config(cfg_sect,"window_width",window_width);
563 zc_set_config(cfg_sect,"window_height",window_height);
564 }
565
566 zc_set_config(cfg_sect,"load_last",loadlast);
567 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
568
569 flush_config_file();
570 #ifdef __EMSCRIPTEN__
571 em_sync_fs();
572 #endif
573 }
574
575 //----------------------------------------------------------------
576
577 // Timers
578
579 47311 void fps_callback()
580 {
581 47311 lastfps=framecnt;
582 47311 framecnt=0;
583 47311 }
584
585 END_OF_FUNCTION(fps_callback)
586
587 262 int32_t Z_init_timers()
588 {
589 static bool didit = false;
590 const static char *err_str = "Couldn't allocate timer";
591 262 err_str = err_str; //Unused variable warning
592
593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
262 if(didit)
594 return 1;
595
596 262 didit = true;
597
598 LOCK_VARIABLE(lastfps);
599 LOCK_VARIABLE(framecnt);
600 LOCK_FUNCTION(fps_callback);
601
602
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
603 return 0;
604
605 262 return 1;
606 262 }
607
608 void Z_remove_timers()
609 {
610 remove_int(fps_callback);
611 }
612
613 //----------------------------------------------------------------
614
615 void go()
616 {
617 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
618 }
619
620 void comeback()
621 {
622 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
623 }
624
625 void dump_pal(BITMAP *dest)
626 {
627 for(int32_t i=0; i<256; i++)
628 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
629 }
630
631 //----------------------------------------------------------------
632
633 int game_mouse_index = ZCM_BLANK;
634 static bool system_mouse = false;
635 176 bool sys_mouse()
636 {
637 176 system_mouse = true;
638 176 return MouseSprite::set(ZCM_NORMAL);
639 }
640 1567 bool game_mouse()
641 {
642 1567 system_mouse = false;
643 1567 return MouseSprite::set(game_mouse_index);
644 }
645 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
646 {
647 if(!bmp)
648 return;
649 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
650 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
651 if(bmp->w == scaledw && bmp->h == scaledh)
652 user_scale = false;
653 if(user_scale || sys_recolor)
654 {
655 if(!user_scale) scale = 1;
656 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
657 if(user_scale)
658 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
659 else
660 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
661 if(sys_recolor)
662 recolor_mouse(tmpbmp);
663 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
664 destroy_bitmap(tmpbmp);
665 }
666 else
667 {
668 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
669 }
670 }
671
672 //Handles converting the mouse sprite from the .dat file
673 27 void recolor_mouse(BITMAP* bmp)
674 {
675
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t x = 0; x < bmp->w; ++x)
676 {
677
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 432 times.
7344 for(int32_t y = 0; y < bmp->h; ++y)
678 {
679 6912 int32_t color = getpixel(bmp, x, y);
680
5/5
✓ Branch 0 taken 4698 times.
✓ Branch 1 taken 513 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 621 times.
✓ Branch 4 taken 486 times.
6912 switch(color)
681 {
682 case dvc(1):
683 513 color = jwin_pal[jcCURSORMISC];
684 513 break;
685 case dvc(2):
686 594 color = jwin_pal[jcCURSOROUTLINE];
687 594 break;
688 case dvc(3):
689 621 color = jwin_pal[jcCURSORLIGHT];
690 621 break;
691 case dvc(5):
692 486 color = jwin_pal[jcCURSORDARK];
693 486 break;
694 default:
695 4698 continue;
696 }
697 2214 putpixel(bmp, x, y, color);
698 2214 }
699 432 }
700 27 }
701 27 void load_mouse()
702 {
703 PALETTE pal;
704 27 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
705
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (!cursor_bitmap)
706 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
707
708 27 enter_sys_pal();
709 27 MouseSprite::set(-1);
710 27 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
711 27 int32_t sz = 16*scale;
712
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t j = 0; j < 1; ++j)
713 {
714 27 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
715
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(zcmouse[j])
716 destroy_bitmap(zcmouse[j]);
717 27 zcmouse[j] = create_bitmap_ex(8,sz,sz);
718 27 clear_bitmap(zcmouse[j]);
719 27 clear_bitmap(tmpbmp);
720 27 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
721 27 recolor_mouse(tmpbmp);
722
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(sz!=16)
723 27 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
724 else
725 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
726 27 destroy_bitmap(tmpbmp);
727 27 }
728
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!hw_palette) hw_palette = &RAMpal;
729 27 zc_set_palette(*hw_palette);
730
731 27 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
732 27 clear_bitmap(blankmouse);
733
734 27 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
735 27 MouseSprite::assign(ZCM_BLANK, blankmouse);
736 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
737
738 //Reload the mouse
739
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(system_mouse)
740 27 sys_mouse();
741 else game_mouse();
742
743 27 destroy_bitmap(blankmouse);
744 27 destroy_bitmap(cursor_bitmap);
745 27 exit_sys_pal();
746 27 }
747
748 // sets the video mode and initializes the palette and mouse sprite
749 262 bool game_vid_mode(int32_t mode,int32_t wait)
750 {
751
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 27 times.
262 if (is_headless())
752 235 return true;
753
754 extern int zq_screen_w, zq_screen_h;
755
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(set_gfx_mode(mode,resx,resy,zq_screen_w,zq_screen_h)!=0)
756 {
757 return false;
758 }
759
760 27 scrx = (resx-320)>>1;
761 27 scry = (resy-240)>>1;
762
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
763 27 zcmouse[q] = NULL;
764 27 load_mouse();
765
766
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 27 times.
459 for(int32_t i=240; i<256; i++)
767 432 RAMpal[i]=pal_gui[i];
768
769 27 zc_set_palette(RAMpal);
770 27 clear_to_color(screen,BLACK);
771
772 27 rest(wait);
773 27 return true;
774 262 }
775
776 271 void null_quest()
777 {
778 char qstdat_string[2048];
779 271 strcpy(qstdat_string, "modules/classic/default.qst");
780
781 #ifdef __EMSCRIPTEN__
782 // The quest template data file is not included because it's really big and isn't really needed
783 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
784 // which is much smaller.
785 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
786 #endif
787
788 271 byte skip_flags[4] = { 0 };
789
790 271 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
791 271 }
792
793 271 void init_NES_mode()
794 {
795 271 null_quest();
796 271 }
797
798 //----------------------------------------------------------------
799
800 qword trianglelines[16]=
801 {
802 0x0000000000000000ULL,
803 0xFD00000000000000ULL,
804 0xFDFD000000000000ULL,
805 0xFDFDFD0000000000ULL,
806 0xFDFDFDFD00000000ULL,
807 0xFDFDFDFDFD000000ULL,
808 0xFDFDFDFDFDFD0000ULL,
809 0xFDFDFDFDFDFDFD00ULL,
810 0xFDFDFDFDFDFDFDFDULL,
811 0x00FDFDFDFDFDFDFDULL,
812 0x0000FDFDFDFDFDFDULL,
813 0x000000FDFDFDFDFDULL,
814 0x00000000FDFDFDFDULL,
815 0x0000000000FDFDFDULL,
816 0x000000000000FDFDULL,
817 0x00000000000000FDULL,
818 };
819
820 word screen_triangles[28][32];
821 /*
822 qword triangles[4][16]= //[direction][value]
823 {
824 {
825 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
826 },
827 {
828 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
829 },
830 {
831 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
832 },
833 {
834 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
835 }
836 };
837 */
838
839
840 /*
841 byte triangles[4][16][8]= //[direction][value][line]
842 {
843 {
844 {
845 0, 0, 0, 0, 0, 0, 0, 0
846 },
847 {
848 1, 0, 0, 0, 0, 0, 0, 0
849 },
850 {
851 2, 1, 0, 0, 0, 0, 0, 0
852 },
853 {
854 3, 2, 1, 0, 0, 0, 0, 0
855 },
856 {
857 4, 3, 2, 1, 0, 0, 0, 0
858 },
859 {
860 5, 4, 3, 2, 1, 0, 0, 0
861 },
862 {
863 6, 5, 4, 3, 2, 1, 0, 0
864 },
865 {
866 7, 6, 5, 4, 3, 2, 1, 0
867 },
868 {
869 8, 7, 6, 5, 4, 3, 2, 1
870 },
871 {
872 8, 8, 7, 6, 5, 4, 3, 2
873 },
874 {
875 8, 8, 8, 7, 6, 5, 4, 3
876 },
877 {
878 8, 8, 8, 8, 7, 6, 5, 4
879 },
880 {
881 8, 8, 8, 8, 8, 7, 6, 5
882 },
883 {
884 8, 8, 8, 8, 8, 8, 7, 6
885 },
886 {
887 8, 8, 8, 8, 8, 8, 8, 7
888 },
889 {
890 8, 8, 8, 8, 8, 8, 8, 8
891 }
892 },
893 {
894 {
895 0, 0, 0, 0, 0, 0, 0, 0
896 },
897 {
898 15, 0, 0, 0, 0, 0, 0, 0
899 },
900 {
901 14, 15, 0, 0, 0, 0, 0, 0
902 },
903 {
904 13, 14, 15, 0, 0, 0, 0, 0
905 },
906 {
907 12, 13, 14, 15, 0, 0, 0, 0
908 },
909 {
910 11, 12, 13, 14, 15, 0, 0, 0
911 },
912 {
913 10, 11, 12, 13, 14, 15, 0, 0
914 },
915 {
916 9, 10, 11, 12, 13, 14, 15, 0
917 },
918 {
919 8, 9, 10, 11, 12, 13, 14, 15
920 },
921 {
922 8, 8, 9, 10, 11, 12, 13, 14
923 },
924 {
925 8, 8, 8, 9, 10, 11, 12, 13
926 },
927 {
928 8, 8, 8, 8, 9, 10, 11, 12
929 },
930 {
931 8, 8, 8, 8, 8, 9, 10, 11
932 },
933 {
934 8, 8, 8, 8, 8, 8, 9, 10
935 },
936 {
937 8, 8, 8, 8, 8, 8, 8, 9
938 },
939 {
940 8, 8, 8, 8, 8, 8, 8, 8
941 }
942 },
943 {
944 {
945 0, 0, 0, 0, 0, 0, 0, 0
946 },
947 {
948 0, 0, 0, 0, 0, 0, 0, 1
949 },
950 {
951 0, 0, 0, 0, 0, 0, 1, 2
952 },
953 {
954 0, 0, 0, 0, 0, 1, 2, 3
955 },
956 {
957 0, 0, 0, 0, 1, 2, 3, 4
958 },
959 {
960 0, 0, 0, 1, 2, 3, 4, 5
961 },
962 {
963 0, 0, 1, 2, 3, 4, 5, 6
964 },
965 {
966 0, 1, 2, 3, 4, 5, 6, 7
967 },
968 {
969 1, 2, 3, 4, 5, 6, 7, 8
970 },
971 {
972 2, 3, 4, 5, 6, 7, 8, 8
973 },
974 {
975 3, 4, 5, 6, 7, 8, 8, 8
976 },
977 {
978 4, 5, 6, 7, 8, 8, 8, 8
979 },
980 {
981 5, 6, 7, 8, 8, 8, 8, 8
982 },
983 {
984 6, 7, 8, 8, 8, 8, 8, 8
985 },
986 {
987 7, 8, 8, 8, 8, 8, 8, 8
988 },
989 {
990 8, 8, 8, 8, 8, 8, 8, 8
991 }
992 },
993 {
994 {
995 0, 0, 0, 0, 0, 0, 0, 0
996 },
997 {
998 0, 0, 0, 0, 0, 0, 0, 15
999 },
1000 {
1001 0, 0, 0, 0, 0, 0, 15, 14
1002 },
1003 {
1004 0, 0, 0, 0, 0, 15, 14, 13
1005 },
1006 {
1007 0, 0, 0, 0, 15, 14, 13, 12
1008 },
1009 {
1010 0, 0, 0, 15, 14, 13, 12, 11
1011 },
1012 {
1013 0, 0, 15, 14, 13, 12, 11, 10
1014 },
1015 {
1016 0, 15, 14, 13, 12, 11, 10, 9
1017 },
1018 {
1019 15, 14, 13, 12, 11, 10, 9, 8
1020 },
1021 {
1022 14, 13, 12, 11, 10, 9, 8, 8
1023 },
1024 {
1025 13, 12, 11, 10, 9, 8, 8, 8
1026 },
1027 {
1028 12, 11, 10, 9, 8, 8, 8, 8
1029 },
1030 {
1031 11, 10, 9, 8, 8, 8, 8, 8
1032 },
1033 {
1034 10, 9, 8, 8, 8, 8, 8, 8
1035 },
1036 {
1037 9, 8, 8, 8, 8, 8, 8, 8
1038 },
1039 {
1040 8, 8, 8, 8, 8, 8, 8, 8
1041 }
1042 }
1043 };
1044 */
1045
1046
1047
1048 /*
1049 for (int32_t blockrow=0; blockrow<30; ++i)
1050 {
1051 for (int32_t linerow=0; linerow<8; ++i)
1052 {
1053 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1054 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1055 {
1056 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1057 ++triangleline;
1058 }
1059 }
1060 }
1061 */
1062
1063 // the ULL suffixes are to prevent this warning:
1064 // warning: integer constant is too large for "int32_t" type
1065
1066 qword triangles[4][16][8]= //[direction][value][line]
1067 {
1068 {
1069 {
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL
1078 },
1079 {
1080 0xFD00000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL,
1087 0x0000000000000000ULL
1088 },
1089 {
1090 0xFDFD000000000000ULL,
1091 0xFD00000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL,
1097 0x0000000000000000ULL
1098 },
1099 {
1100 0xFDFDFD0000000000ULL,
1101 0xFDFD000000000000ULL,
1102 0xFD00000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL,
1107 0x0000000000000000ULL
1108 },
1109 {
1110 0xFDFDFDFD00000000ULL,
1111 0xFDFDFD0000000000ULL,
1112 0xFDFD000000000000ULL,
1113 0xFD00000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL,
1117 0x0000000000000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFD000000ULL,
1121 0xFDFDFDFD00000000ULL,
1122 0xFDFDFD0000000000ULL,
1123 0xFDFD000000000000ULL,
1124 0xFD00000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL,
1127 0x0000000000000000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFD0000ULL,
1131 0xFDFDFDFDFD000000ULL,
1132 0xFDFDFDFD00000000ULL,
1133 0xFDFDFD0000000000ULL,
1134 0xFDFD000000000000ULL,
1135 0xFD00000000000000ULL,
1136 0x0000000000000000ULL,
1137 0x0000000000000000ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFD00ULL,
1141 0xFDFDFDFDFDFD0000ULL,
1142 0xFDFDFDFDFD000000ULL,
1143 0xFDFDFDFD00000000ULL,
1144 0xFDFDFD0000000000ULL,
1145 0xFDFD000000000000ULL,
1146 0xFD00000000000000ULL,
1147 0x0000000000000000ULL
1148 },
1149 {
1150 0xFDFDFDFDFDFDFDFDULL,
1151 0xFDFDFDFDFDFDFD00ULL,
1152 0xFDFDFDFDFDFD0000ULL,
1153 0xFDFDFDFDFD000000ULL,
1154 0xFDFDFDFD00000000ULL,
1155 0xFDFDFD0000000000ULL,
1156 0xFDFD000000000000ULL,
1157 0xFD00000000000000ULL
1158 },
1159 {
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFDFDULL,
1162 0xFDFDFDFDFDFDFD00ULL,
1163 0xFDFDFDFDFDFD0000ULL,
1164 0xFDFDFDFDFD000000ULL,
1165 0xFDFDFDFD00000000ULL,
1166 0xFDFDFD0000000000ULL,
1167 0xFDFD000000000000ULL
1168 },
1169 {
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFDFDULL,
1173 0xFDFDFDFDFDFDFD00ULL,
1174 0xFDFDFDFDFDFD0000ULL,
1175 0xFDFDFDFDFD000000ULL,
1176 0xFDFDFDFD00000000ULL,
1177 0xFDFDFD0000000000ULL
1178 },
1179 {
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFD00ULL,
1185 0xFDFDFDFDFDFD0000ULL,
1186 0xFDFDFDFDFD000000ULL,
1187 0xFDFDFDFD00000000ULL
1188 },
1189 {
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFD00ULL,
1196 0xFDFDFDFDFDFD0000ULL,
1197 0xFDFDFDFDFD000000ULL
1198 },
1199 {
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFDFDULL,
1206 0xFDFDFDFDFDFDFD00ULL,
1207 0xFDFDFDFDFDFD0000ULL
1208 },
1209 {
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFD00ULL
1218 },
1219 {
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL,
1227 0xFDFDFDFDFDFDFDFDULL
1228 }
1229 },
1230 {
1231 {
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL
1240 },
1241 {
1242 0x00000000000000FDULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL,
1249 0x0000000000000000ULL
1250 },
1251 {
1252 0x000000000000FDFDULL,
1253 0x00000000000000FDULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL,
1259 0x0000000000000000ULL
1260 },
1261 {
1262 0x0000000000FDFDFDULL,
1263 0x000000000000FDFDULL,
1264 0x00000000000000FDULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL,
1269 0x0000000000000000ULL
1270 },
1271 {
1272 0x00000000FDFDFDFDULL,
1273 0x0000000000FDFDFDULL,
1274 0x000000000000FDFDULL,
1275 0x00000000000000FDULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL,
1279 0x0000000000000000ULL
1280 },
1281 {
1282 0x000000FDFDFDFDFDULL,
1283 0x00000000FDFDFDFDULL,
1284 0x0000000000FDFDFDULL,
1285 0x000000000000FDFDULL,
1286 0x00000000000000FDULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL,
1289 0x0000000000000000ULL
1290 },
1291 {
1292 0x0000FDFDFDFDFDFDULL,
1293 0x000000FDFDFDFDFDULL,
1294 0x00000000FDFDFDFDULL,
1295 0x0000000000FDFDFDULL,
1296 0x000000000000FDFDULL,
1297 0x00000000000000FDULL,
1298 0x0000000000000000ULL,
1299 0x0000000000000000ULL
1300 },
1301 {
1302 0x00FDFDFDFDFDFDFDULL,
1303 0x0000FDFDFDFDFDFDULL,
1304 0x000000FDFDFDFDFDULL,
1305 0x00000000FDFDFDFDULL,
1306 0x0000000000FDFDFDULL,
1307 0x000000000000FDFDULL,
1308 0x00000000000000FDULL,
1309 0x0000000000000000ULL
1310 },
1311 {
1312 0xFDFDFDFDFDFDFDFDULL,
1313 0x00FDFDFDFDFDFDFDULL,
1314 0x0000FDFDFDFDFDFDULL,
1315 0x000000FDFDFDFDFDULL,
1316 0x00000000FDFDFDFDULL,
1317 0x0000000000FDFDFDULL,
1318 0x000000000000FDFDULL,
1319 0x00000000000000FDULL
1320 },
1321 {
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0xFDFDFDFDFDFDFDFDULL,
1324 0x00FDFDFDFDFDFDFDULL,
1325 0x0000FDFDFDFDFDFDULL,
1326 0x000000FDFDFDFDFDULL,
1327 0x00000000FDFDFDFDULL,
1328 0x0000000000FDFDFDULL,
1329 0x000000000000FDFDULL
1330 },
1331 {
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0xFDFDFDFDFDFDFDFDULL,
1335 0x00FDFDFDFDFDFDFDULL,
1336 0x0000FDFDFDFDFDFDULL,
1337 0x000000FDFDFDFDFDULL,
1338 0x00000000FDFDFDFDULL,
1339 0x0000000000FDFDFDULL
1340 },
1341 {
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0x00FDFDFDFDFDFDFDULL,
1347 0x0000FDFDFDFDFDFDULL,
1348 0x000000FDFDFDFDFDULL,
1349 0x00000000FDFDFDFDULL
1350 },
1351 {
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0x00FDFDFDFDFDFDFDULL,
1358 0x0000FDFDFDFDFDFDULL,
1359 0x000000FDFDFDFDFDULL
1360 },
1361 {
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0xFDFDFDFDFDFDFDFDULL,
1368 0x00FDFDFDFDFDFDFDULL,
1369 0x0000FDFDFDFDFDFDULL
1370 },
1371 {
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0x00FDFDFDFDFDFDFDULL
1380 },
1381 {
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL,
1389 0xFDFDFDFDFDFDFDFDULL
1390 }
1391 },
1392 {
1393 {
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL
1402 },
1403 {
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0xFD00000000000000ULL
1412 },
1413 {
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0xFD00000000000000ULL,
1421 0xFDFD000000000000ULL
1422 },
1423 {
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0xFD00000000000000ULL,
1430 0xFDFD000000000000ULL,
1431 0xFDFDFD0000000000ULL
1432 },
1433 {
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL,
1439 0xFDFD000000000000ULL,
1440 0xFDFDFD0000000000ULL,
1441 0xFDFDFDFD00000000ULL
1442 },
1443 {
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL,
1449 0xFDFDFD0000000000ULL,
1450 0xFDFDFDFD00000000ULL,
1451 0xFDFDFDFDFD000000ULL
1452 },
1453 {
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0xFD00000000000000ULL,
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL,
1459 0xFDFDFDFD00000000ULL,
1460 0xFDFDFDFDFD000000ULL,
1461 0xFDFDFDFDFDFD0000ULL
1462 },
1463 {
1464 0x0000000000000000ULL,
1465 0xFD00000000000000ULL,
1466 0xFDFD000000000000ULL,
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL,
1469 0xFDFDFDFDFD000000ULL,
1470 0xFDFDFDFDFDFD0000ULL,
1471 0xFDFDFDFDFDFDFD00ULL
1472 },
1473 {
1474 0xFD00000000000000ULL,
1475 0xFDFD000000000000ULL,
1476 0xFDFDFD0000000000ULL,
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL,
1479 0xFDFDFDFDFDFD0000ULL,
1480 0xFDFDFDFDFDFDFD00ULL,
1481 0xFDFDFDFDFDFDFDFDULL
1482 },
1483 {
1484 0xFDFD000000000000ULL,
1485 0xFDFDFD0000000000ULL,
1486 0xFDFDFDFD00000000ULL,
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL,
1489 0xFDFDFDFDFDFDFD00ULL,
1490 0xFDFDFDFDFDFDFDFDULL,
1491 0xFDFDFDFDFDFDFDFDULL
1492 },
1493 {
1494 0xFDFDFD0000000000ULL,
1495 0xFDFDFDFD00000000ULL,
1496 0xFDFDFDFDFD000000ULL,
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL
1502 },
1503 {
1504 0xFDFDFDFD00000000ULL,
1505 0xFDFDFDFDFD000000ULL,
1506 0xFDFDFDFDFDFD0000ULL,
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL
1512 },
1513 {
1514 0xFDFDFDFDFD000000ULL,
1515 0xFDFDFDFDFDFD0000ULL,
1516 0xFDFDFDFDFDFDFD00ULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL
1522 },
1523 {
1524 0xFDFDFDFDFDFD0000ULL,
1525 0xFDFDFDFDFDFDFD00ULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL
1532 },
1533 {
1534 0xFDFDFDFDFDFDFD00ULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL
1542 },
1543 {
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL,
1551 0xFDFDFDFDFDFDFDFDULL
1552 }
1553 },
1554 {
1555 {
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL
1564 },
1565 {
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x00000000000000FDULL
1574 },
1575 {
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x00000000000000FDULL,
1583 0x000000000000FDFDULL
1584 },
1585 {
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x00000000000000FDULL,
1592 0x000000000000FDFDULL,
1593 0x0000000000FDFDFDULL
1594 },
1595 {
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL,
1601 0x000000000000FDFDULL,
1602 0x0000000000FDFDFDULL,
1603 0x00000000FDFDFDFDULL
1604 },
1605 {
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL,
1611 0x0000000000FDFDFDULL,
1612 0x00000000FDFDFDFDULL,
1613 0x000000FDFDFDFDFDULL
1614 },
1615 {
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x00000000000000FDULL,
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL,
1621 0x00000000FDFDFDFDULL,
1622 0x000000FDFDFDFDFDULL,
1623 0x0000FDFDFDFDFDFDULL
1624 },
1625 {
1626 0x0000000000000000ULL,
1627 0x00000000000000FDULL,
1628 0x000000000000FDFDULL,
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL,
1631 0x000000FDFDFDFDFDULL,
1632 0x0000FDFDFDFDFDFDULL,
1633 0x00FDFDFDFDFDFDFDULL
1634 },
1635 {
1636 0x00000000000000FDULL,
1637 0x000000000000FDFDULL,
1638 0x0000000000FDFDFDULL,
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL,
1641 0x0000FDFDFDFDFDFDULL,
1642 0x00FDFDFDFDFDFDFDULL,
1643 0xFDFDFDFDFDFDFDFDULL
1644 },
1645 {
1646 0x000000000000FDFDULL,
1647 0x0000000000FDFDFDULL,
1648 0x00000000FDFDFDFDULL,
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL,
1651 0x00FDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL,
1653 0xFDFDFDFDFDFDFDFDULL
1654 },
1655 {
1656 0x0000000000FDFDFDULL,
1657 0x00000000FDFDFDFDULL,
1658 0x000000FDFDFDFDFDULL,
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL
1664 },
1665 {
1666 0x00000000FDFDFDFDULL,
1667 0x000000FDFDFDFDFDULL,
1668 0x0000FDFDFDFDFDFDULL,
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL
1674 },
1675 {
1676 0x000000FDFDFDFDFDULL,
1677 0x0000FDFDFDFDFDFDULL,
1678 0x00FDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL
1684 },
1685 {
1686 0x0000FDFDFDFDFDFDULL,
1687 0x00FDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL
1694 },
1695 {
1696 0x00FDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL
1704 },
1705 {
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL,
1713 0xFDFDFDFDFDFDFDFDULL
1714 }
1715 }
1716 };
1717
1718 int32_t black_opening_count=0;
1719 int32_t black_opening_x,black_opening_y;
1720 int32_t black_opening_shape;
1721
1722 3227 int32_t choose_opening_shape()
1723 {
1724 // First, count how many bits are set
1725 3227 int32_t numBits=0;
1726 int32_t bitCounter;
1727
1728
2/2
✓ Branch 0 taken 16135 times.
✓ Branch 1 taken 3227 times.
19362 for(int32_t i=0; i<bosMAX; i++)
1729 {
1730
2/2
✓ Branch 0 taken 12692 times.
✓ Branch 1 taken 3443 times.
16135 if(COOLSCROLL&(1<<i))
1731 3443 numBits++;
1732 16135 }
1733
1734 // Shouldn't happen...
1735
1/2
✓ Branch 0 taken 3227 times.
✗ Branch 1 not taken.
3227 if(numBits==0)
1736 return bosCIRCLE;
1737
1738 // Pick a bit
1739 3227 bitCounter=zc_rand()%numBits+1;
1740
1741
2/2
✓ Branch 0 taken 4418 times.
✓ Branch 1 taken 26 times.
4444 for(int32_t i=0; i<bosMAX; i++)
1742 {
1743 // If this bit is set, decrement the bit counter
1744
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 3357 times.
4418 if(COOLSCROLL&(1<<i))
1745 3357 bitCounter--;
1746
1747 // When the counter hits 0, return a value based on
1748 // which bit it stopped on.
1749 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1750
2/2
✓ Branch 0 taken 3201 times.
✓ Branch 1 taken 1217 times.
4418 if(bitCounter==0)
1751 3201 return i;
1752 1217 }
1753
1754 // Shouldn't be necessary, but the compiler might complain, at least
1755 26 return bosCIRCLE;
1756 3227 }
1757
1758 727 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1759 {
1760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1761
1762 727 int32_t w=256, h=224;
1763 727 int32_t blockrows=28, blockcolumns=32;
1764 727 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1765
1766
2/2
✓ Branch 0 taken 20356 times.
✓ Branch 1 taken 727 times.
21083 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1767 {
1768
2/2
✓ Branch 0 taken 651392 times.
✓ Branch 1 taken 20356 times.
671748 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1769 {
1770
2/2
✓ Branch 0 taken 269309 times.
✓ Branch 1 taken 382083 times.
651392 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1771 651392 }
1772 20356 }
1773
1774 727 black_opening_count = 66;
1775 727 black_opening_x = x;
1776 727 black_opening_y = y;
1777 727 lensclk = 0;
1778 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1779
1780
1781
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(black_opening_shape == bosFADEBLACK)
1782 {
1783 refreshTints();
1784 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1785 }
1786
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 4 times.
727 if(wait)
1787 {
1788 4 FFCore.warpScriptCheck();
1789
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 264 times.
268 for(int32_t i=0; i<66; i++)
1790 {
1791 264 draw_screen(tmpscr);
1792 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1793 264 advanceframe(true);
1794
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Quit)
1796 {
1797 break;
1798 }
1799 264 }
1800 4 }
1801 727 }
1802
1803 2500 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1804 {
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2500 times.
2500 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1806
1807 2500 int32_t w=256, h=224;
1808 2500 int32_t blockrows=28, blockcolumns=32;
1809 2500 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1810
1811
2/2
✓ Branch 0 taken 70000 times.
✓ Branch 1 taken 2500 times.
72500 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1812 {
1813
2/2
✓ Branch 0 taken 2240000 times.
✓ Branch 1 taken 70000 times.
2310000 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1814 {
1815
2/2
✓ Branch 0 taken 1103411 times.
✓ Branch 1 taken 1136589 times.
2240000 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1816 2240000 }
1817 70000 }
1818
1819 2500 black_opening_count = -66;
1820 2500 black_opening_x = x;
1821 2500 black_opening_y = y;
1822 2500 lensclk = 0;
1823
1/2
✓ Branch 0 taken 2500 times.
✗ Branch 1 not taken.
2500 if(black_opening_shape == bosFADEBLACK)
1824 {
1825 refreshTints();
1826 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1827 }
1828
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 2135 times.
2500 if(wait)
1829 {
1830 2135 FFCore.warpScriptCheck();
1831
2/2
✓ Branch 0 taken 2134 times.
✓ Branch 1 taken 140913 times.
143047 for(int32_t i=0; i<66; i++)
1832 {
1833 140913 draw_screen(tmpscr);
1834 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1835 140913 advanceframe(true);
1836
1837
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 140912 times.
140913 if(Quit)
1838 {
1839 1 break;
1840 }
1841 140912 }
1842 2135 }
1843 2500 }
1844
1845 212401 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1846 {
1847 212401 clear_to_color(tmp_scr,BLACK);
1848 212401 int32_t w=256, h=224;
1849
1850
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9636 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 20262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 181843 times.
212401 switch(black_opening_shape)
1851 {
1852 case bosOVAL:
1853 {
1854 9636 double new_w=(w/2)+abs(w/2-x);
1855 9636 double new_h=(h/2)+abs(h/2-y);
1856 9636 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1857 9636 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1858 9636 break;
1859 }
1860
1861 case bosTRIANGLE:
1862 {
1863 660 double new_w=(w/2)+abs(w/2-x);
1864 660 double new_h=(h/2)+abs(h/2-y);
1865 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1866 660 double P2= (PI/2);
1867 660 double P23=(2*PI/3);
1868 660 double P43=(4*PI/3);
1869 660 double Pa= (-4*PI*a/(3*max_a));
1870 660 double angle=P2+Pa;
1871 660 double a0=angle;
1872 660 double a2=angle+P23;
1873 660 double a4=angle+P43;
1874 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1875 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1876 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1877 0);
1878 660 break;
1879 }
1880
1881 case bosSMAS:
1882 {
1883
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 13068 times.
20262 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1884
1885
2/2
✓ Branch 0 taken 567336 times.
✓ Branch 1 taken 20262 times.
587598 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1886 {
1887
2/2
✓ Branch 0 taken 4538688 times.
✓ Branch 1 taken 567336 times.
5106024 for(int32_t linerow=0; linerow<8; ++linerow)
1888 {
1889 4538688 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1890
1891
2/2
✓ Branch 0 taken 145238016 times.
✓ Branch 1 taken 4538688 times.
149776704 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1892 {
1893 435714048 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1894
6/6
✓ Branch 0 taken 104912184 times.
✓ Branch 1 taken 40325832 times.
✓ Branch 2 taken 95821040 times.
✓ Branch 3 taken 49416976 times.
✓ Branch 4 taken 55495208 times.
✓ Branch 5 taken 40325832 times.
145238016 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1895 145238016 [linerow];
1896 145238016 ++triangleline;
1897
1898
2/2
✓ Branch 0 taken 127083264 times.
✓ Branch 1 taken 18154752 times.
145238016 if(linerow==0)
1899 {
1900 18154752 }
1901 145238016 }
1902 4538688 }
1903 567336 }
1904
1905 20262 break;
1906 }
1907
1908 case bosFADEBLACK:
1909 {
1910 if(black_opening_count<0)
1911 {
1912 black_fade(zc_min(-black_opening_count,63));
1913 }
1914 else if(black_opening_count>0)
1915 {
1916 black_fade(63-zc_max(black_opening_count-3,0));
1917 }
1918 else black_fade(0);
1919 return; //no blitting from tmp_scr!
1920 }
1921
1922 181843 case bosCIRCLE:
1923 default:
1924 {
1925 181843 double new_w=(w/2)+abs(w/2-x);
1926 181843 double new_h=(h/2)+abs(h/2-y);
1927 181843 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1928 //circlefill(tmp_scr,x,y,a<<3,0);
1929 181843 circlefill(tmp_scr,x,y,r,0);
1930 181843 break;
1931 }
1932 }
1933
1934 212401 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1935 212401 }
1936
1937
1938 void black_fade(int32_t fadeamnt)
1939 {
1940 for(int32_t i=0; i < 0xEF; i++)
1941 {
1942 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1943 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1944 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1945 }
1946
1947 refreshpal = true;
1948 }
1949
1950 //----------------------------------------------------------------
1951
1952 200165128 bool item_disabled(int32_t item) //is this item disabled?
1953 {
1954
2/2
✓ Branch 0 taken 14429052 times.
✓ Branch 1 taken 185736076 times.
200165128 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1955 }
1956
1957 15452733 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1958 {
1959
2/2
✓ Branch 0 taken 187919 times.
✓ Branch 1 taken 15264814 times.
15452733 if(current_item(item_type, true) >=item)
1960 {
1961 187919 return true;
1962 }
1963
1964 15264814 return false;
1965 15452733 }
1966
1967 48039022 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1968 {
1969
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4363813 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4902235 times.
✓ Branch 6 taken 28693221 times.
✓ Branch 7 taken 9885299 times.
✓ Branch 8 taken 194454 times.
48039022 switch(item_type)
1970 {
1971 case itype_bomb:
1972 case itype_sbomb:
1973 {
1974 int32_t itemid = getItemID(itemsbuf, item_type, it);
1975
1976 if(itemid == -1)
1977 return false;
1978
1979 return (game->get_item(itemid));
1980 }
1981
1982 case itype_clock:
1983 {
1984 4363813 int32_t itemid = getItemID(itemsbuf, item_type, it);
1985
1986
2/4
✓ Branch 0 taken 4363813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4363813 times.
✗ Branch 3 not taken.
4363813 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1987 return (game->get_item(itemid));
1988 4363813 return Hero.getClock()?1:0;
1989 }
1990
1991 case itype_key:
1992 return (game->get_keys()>0);
1993
1994 case itype_magiccontainer:
1995 return (game->get_maxmagic()>=game->get_mp_per_block());
1996
1997 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1998 {
1999
2/3
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4581019 times.
4902235 switch(it)
2000 {
2001 case -2:
2002 {
2003 for(int32_t i=0; i<MAXLEVELS; i++)
2004 {
2005 if(game->lvlitems[i]&liTRIFORCE)
2006 {
2007 return true;
2008 }
2009 }
2010
2011 return false;
2012 }
2013
2014 case -1:
2015 4581019 return (game->lvlitems[dlevel]&liTRIFORCE);
2016
2017 default:
2018
2/4
✓ Branch 0 taken 321216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321216 times.
321216 if(it>=0&&it<MAXLEVELS)
2019 {
2020 321216 return (game->lvlitems[it]&liTRIFORCE);
2021 }
2022
2023 break;
2024 }
2025
2026 return 0;
2027 }
2028
2029 case itype_map: //it: -2=any, -1=current level, other=that level
2030 {
2031
2/3
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28152819 times.
28693221 switch(it)
2032 {
2033 case -2:
2034 {
2035 for(int32_t i=0; i<MAXLEVELS; i++)
2036 {
2037 if(game->lvlitems[i]&liMAP)
2038 {
2039 return true;
2040 }
2041 }
2042
2043 return false;
2044 }
2045
2046 case -1:
2047 28152819 return (game->lvlitems[dlevel]&liMAP)!=0;
2048
2049 default:
2050
2/4
✓ Branch 0 taken 540402 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540402 times.
540402 if(it>=0&&it<MAXLEVELS)
2051 {
2052 540402 return (game->lvlitems[it]&liMAP)!=0;
2053 }
2054
2055 break;
2056 }
2057
2058 return 0;
2059 }
2060
2061 case itype_compass: //it: -2=any, -1=current level, other=that level
2062 {
2063
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 9885299 times.
9885299 switch(it)
2064 {
2065 case -2:
2066 {
2067 for(int32_t i=0; i<MAXLEVELS; i++)
2068 {
2069 if(game->lvlitems[i]&liCOMPASS)
2070 {
2071 return true;
2072 }
2073 }
2074
2075 return false;
2076 }
2077
2078 case -1:
2079 9885299 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2080
2081 default:
2082 if(it>=0&&it<MAXLEVELS)
2083 {
2084 return (game->lvlitems[it]&liCOMPASS)!=0;
2085 }
2086
2087 break;
2088 }
2089 return 0;
2090 }
2091
2092 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2093 {
2094
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 194454 times.
194454 switch(it)
2095 {
2096 case -2:
2097 {
2098 for(int32_t i=0; i<MAXLEVELS; i++)
2099 {
2100 if(game->lvlitems[i]&liBOSSKEY)
2101 {
2102 return true;
2103 }
2104 }
2105
2106 return false;
2107 }
2108
2109 case -1:
2110 194454 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2111
2112 default:
2113 if(it>=0&&it<MAXLEVELS)
2114 {
2115 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2116 }
2117 break;
2118 }
2119 return 0;
2120 }
2121
2122 default:
2123 //it=(1<<(it-1));
2124 /*if (item_type>=itype_max)
2125 {
2126 enter_sys_pal();
2127 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2128 exit_sys_pal();
2129
2130 return false;
2131 }*/
2132 int32_t itemid = getItemID(itemsbuf, item_type, it);
2133
2134 if(itemid == -1)
2135 return false;
2136
2137 return game->get_item(itemid);
2138 }
2139 48039022 }
2140
2141 149138387 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
2142 {
2143
9/9
✓ Branch 0 taken 4363813 times.
✓ Branch 1 taken 114227883 times.
✓ Branch 2 taken 4363813 times.
✓ Branch 3 taken 4363813 times.
✓ Branch 4 taken 4363813 times.
✓ Branch 5 taken 4363813 times.
✓ Branch 6 taken 4363813 times.
✓ Branch 7 taken 4363813 times.
✓ Branch 8 taken 4363813 times.
149138387 switch(item_type)
2144 {
2145 case itype_clock:
2146 {
2147 4363813 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2148
2149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4363813 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4363813 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2150 return itemsbuf[maxid].fam_type;
2151
2152 4363813 return has_item(itype_clock,1) ? 1 : 0;
2153 }
2154
2155 case itype_key:
2156 4363813 return game->get_keys();
2157
2158 case itype_lkey:
2159 4363813 return game->lvlkeys[get_dlevel()];
2160
2161 case itype_magiccontainer:
2162 4363813 return game->get_maxmagic()/game->get_mp_per_block();
2163
2164 case itype_triforcepiece:
2165 {
2166 4363813 int count=0;
2167
2168
2/2
✓ Branch 0 taken 2234272256 times.
✓ Branch 1 taken 4363813 times.
2238636069 for(int i=0; i<MAXLEVELS; i++)
2169 {
2170 2234272256 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2171 2234272256 }
2172
2173 4363813 return count;
2174 }
2175
2176 case itype_map:
2177 {
2178 4363813 int count=0;
2179
2180
2/2
✓ Branch 0 taken 2234272256 times.
✓ Branch 1 taken 4363813 times.
2238636069 for(int i=0; i<MAXLEVELS; i++)
2181 {
2182 2234272256 count+=(game->lvlitems[i]&liMAP)?1:0;
2183 2234272256 }
2184
2185 4363813 return count;
2186 }
2187
2188 case itype_compass:
2189 {
2190 4363813 int count=0;
2191
2192
2/2
✓ Branch 0 taken 2234272256 times.
✓ Branch 1 taken 4363813 times.
2238636069 for(int i=0; i<MAXLEVELS; i++)
2193 {
2194 2234272256 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2195 2234272256 }
2196
2197 4363813 return count;
2198 }
2199
2200 case itype_bosskey:
2201 {
2202 4363813 int count=0;
2203
2204
2/2
✓ Branch 0 taken 2234272256 times.
✓ Branch 1 taken 4363813 times.
2238636069 for(int i=0; i<MAXLEVELS; i++)
2205 {
2206 2234272256 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2207 2234272256 }
2208
2209 4363813 return count;
2210 }
2211
2212 default:
2213 114227883 int maxid = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
2214
2215
2/2
✓ Branch 0 taken 33013406 times.
✓ Branch 1 taken 81214477 times.
114227883 if(maxid == -1)
2216 81214477 return 0;
2217
2218 33013406 return itemsbuf[maxid].fam_type;
2219 }
2220 149138387 }
2221
2222 350 std::map<int32_t, int32_t> itemcache;
2223 350 std::map<int32_t, int32_t> itemcache_cost;
2224
2225 void removeFromItemCache(int32_t itemclass)
2226 {
2227 itemcache.erase(itemclass);
2228 itemcache_cost.erase(itemclass);
2229 cache_tile_mod_clear();
2230 }
2231
2232 12381237 void flushItemCache(bool justcost)
2233 {
2234 12381237 itemcache_cost.clear();
2235
2/2
✓ Branch 0 taken 12314916 times.
✓ Branch 1 taken 66321 times.
12381237 if(!justcost)
2236 66321 itemcache.clear();
2237
2/2
✓ Branch 0 taken 5826470 times.
✓ Branch 1 taken 6488446 times.
12314916 else if(replay_version_check(0,19))
2238 5826470 return;
2239
2240 6554767 cache_tile_mod_clear();
2241
2242 //also fix the active subscreen if items were deleted -DD
2243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6554767 times.
6554767 if(game != NULL)
2244 {
2245 6554767 verifyBothWeapons();
2246 6554767 refresh_subscr_items();
2247 6554767 }
2248 12381237 }
2249
2250 // This is used often, so it should be as direct as possible.
2251 2942818997 int _c_item_id_internal(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2252 {
2253 2942818997 bool use_cost_cache = replay_version_check(19);
2254
2/2
✓ Branch 0 taken 2822892679 times.
✓ Branch 1 taken 119926318 times.
2942818997 if(jinx_check)
2255 {
2256
4/4
✓ Branch 0 taken 86881234 times.
✓ Branch 1 taken 33045084 times.
✓ Branch 2 taken 11013560 times.
✓ Branch 3 taken 75867674 times.
119926318 if(!(HeroSwordClk() || HeroItemClk()))
2257 75867674 jinx_check = false; //not jinxed
2258 119926318 }
2259
4/4
✓ Branch 0 taken 103098 times.
✓ Branch 1 taken 2942715899 times.
✓ Branch 2 taken 1853 times.
✓ Branch 3 taken 101245 times.
2942818997 if(!Hero.BunnyClock() || itemtype == itype_pearl) // bunny_check does not apply
2260 2942717752 check_bunny = false;
2261
2/2
✓ Branch 0 taken 2886953914 times.
✓ Branch 1 taken 55865083 times.
2942818997 if(itemtype == itype_ring) checkmagic = true;
2262
4/4
✓ Branch 0 taken 2898760353 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 274389087 times.
✓ Branch 3 taken 23761870 times.
3240969954 if (!jinx_check && !check_bunny
2263
4/4
✓ Branch 0 taken 2898681106 times.
✓ Branch 1 taken 79247 times.
✓ Branch 2 taken 298150957 times.
✓ Branch 3 taken 2600530149 times.
2898760353 && (use_cost_cache || itemtype != itype_ring))
2264 {
2265
4/4
✓ Branch 0 taken 537549967 times.
✓ Branch 1 taken 2337369269 times.
✓ Branch 2 taken 232608595 times.
✓ Branch 3 taken 304941372 times.
2874919236 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2266 2874919236 auto res = cache.find(itemtype);
2267
2268
2/2
✓ Branch 0 taken 2730980509 times.
✓ Branch 1 taken 143938727 times.
2874919236 if(res != cache.end())
2269 2730980509 return res->second;
2270 143938727 }
2271
2272 211838488 int result = -1;
2273 211838488 int highestlevel = -1;
2274
2275
2/2
✓ Branch 0 taken 54230652928 times.
✓ Branch 1 taken 211838488 times.
54442491416 for(int i=0; i<MAXITEMS; i++)
2276 {
2277
6/6
✓ Branch 0 taken 5952166458 times.
✓ Branch 1 taken 48278486470 times.
✓ Branch 2 taken 97390032 times.
✓ Branch 3 taken 5854776426 times.
✓ Branch 4 taken 82048 times.
✓ Branch 5 taken 97307984 times.
54230652928 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2278 {
2279
4/4
✓ Branch 0 taken 92549669 times.
✓ Branch 1 taken 4758315 times.
✓ Branch 2 taken 2425909 times.
✓ Branch 3 taken 90123760 times.
97307984 if(checkmagic && itemtype != itype_magicring)
2280
2/2
✓ Branch 0 taken 90123143 times.
✓ Branch 1 taken 617 times.
90123760 if(!checkmagiccost(i))
2281 617 continue;
2282
6/6
✓ Branch 0 taken 88368207 times.
✓ Branch 1 taken 8939160 times.
✓ Branch 2 taken 1253626 times.
✓ Branch 3 taken 7685534 times.
✓ Branch 4 taken 5007993 times.
✓ Branch 5 taken 3931167 times.
97307367 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3931167 times.
3931167 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2284 3931167 continue;
2285
3/4
✓ Branch 0 taken 86055 times.
✓ Branch 1 taken 93290145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86055 times.
93376200 if(check_bunny && !checkbunny(i))
2286 86055 continue;
2287
2288
2/2
✓ Branch 0 taken 9055010 times.
✓ Branch 1 taken 84235135 times.
93290145 if(itemsbuf[i].fam_type >= highestlevel)
2289 {
2290 84235135 highestlevel = itemsbuf[i].fam_type;
2291 84235135 result=i;
2292 84235135 }
2293 93290145 }
2294 54226635089 }
2295
2296
4/4
✓ Branch 0 taken 167779844 times.
✓ Branch 1 taken 44058644 times.
✓ Branch 2 taken 79247 times.
✓ Branch 3 taken 167700597 times.
211838488 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2297 {
2298
2/2
✓ Branch 0 taken 127938818 times.
✓ Branch 1 taken 39761779 times.
167700597 if (use_cost_cache)
2299 {
2300
2/2
✓ Branch 0 taken 112191293 times.
✓ Branch 1 taken 15747525 times.
127938818 if (!checkmagic)
2301 15747525 itemcache[itemtype] = result;
2302
6/6
✓ Branch 0 taken 15747525 times.
✓ Branch 1 taken 112191293 times.
✓ Branch 2 taken 659514 times.
✓ Branch 3 taken 15088011 times.
✓ Branch 4 taken 646885 times.
✓ Branch 5 taken 12629 times.
127938818 if (checkmagic || result < 0 || checkmagiccost(result))
2303 127926189 itemcache_cost[itemtype] = result;
2304 127938818 }
2305 else
2306 {
2307 39761779 itemcache[itemtype] = result;
2308 }
2309 167700597 }
2310 211838488 return result;
2311 2942818997 }
2312
2313 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2314 2899855478 int current_item_id(int itype, bool checkmagic, bool jinx_check, bool check_bunny)
2315 {
2316
2/4
✓ Branch 0 taken 2899855478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2899855478 times.
2899855478 if(itype < 0 || itype >= itype_max) return -1;
2317
1/2
✓ Branch 0 taken 2899855478 times.
✗ Branch 1 not taken.
2899855478 if(game->OverrideItems[itype] > -2)
2318 {
2319 auto ovid = game->OverrideItems[itype];
2320 if(ovid < 0 || ovid >= MAXITEMS)
2321 return -1;
2322 if(itemsbuf[ovid].family == itype)
2323 {
2324 if(itype == itype_magicring)
2325 checkmagic = false;
2326 else if(itype == itype_ring)
2327 checkmagic = true;
2328
2329 if(checkmagic && !checkmagiccost(ovid))
2330 return -1;
2331 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2332 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2333 return -1;
2334 return ovid;
2335 }
2336 }
2337 2899855478 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2338
2/2
✓ Branch 0 taken 76962799 times.
✓ Branch 1 taken 2822892679 times.
2899855478 if(!jinx_check) //If not already a jinx-immune-only check...
2339 {
2340 //And the player IS jinxed...
2341
4/4
✓ Branch 0 taken 2790687096 times.
✓ Branch 1 taken 32205583 times.
✓ Branch 2 taken 10757936 times.
✓ Branch 3 taken 2779929160 times.
2822892679 if(HeroSwordClk() || HeroItemClk())
2342 {
2343 //Then do a jinx-immune-only check here
2344 42963519 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2345 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2346 //Should NOT need a compat rule, as this should always return -1 in old quests.
2347
2/2
✓ Branch 0 taken 3272877 times.
✓ Branch 1 taken 39690642 times.
42963519 if(ret2 > -1) return ret2;
2348 39690642 }
2349 2819619802 }
2350 2896582601 return ret;
2351 2899855478 }
2352
2353 46361973 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2354 {
2355 46361973 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
2356
2/2
✓ Branch 0 taken 26826291 times.
✓ Branch 1 taken 19535682 times.
46361973 return (result<0) ? 0 : itemsbuf[result].power;
2357 }
2358
2359 26 int32_t heart_container_id()
2360 {
2361
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 for(int32_t i=0; i<MAXITEMS; i++)
2362 {
2363
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 728 times.
754 if(itemsbuf[i].family == itype_heartcontainer)
2364 {
2365 26 return i;
2366 }
2367 728 }
2368 return -1;
2369 26 }
2370
2371 struct tilemod_cache_state_t
2372 {
2373
6/6
✓ Branch 0 taken 4363459 times.
✓ Branch 1 taken 8415265 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8415263 times.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 8414911 times.
21193989 bool operator==(const tilemod_cache_state_t&) const = default;
2374
2375 bool valid;
2376 bool bunny_clock;
2377 bool superman;
2378 int shield;
2379 };
2380 tilemod_cache_state_t tilemod_cache_state;
2381 int32_t tilemod_cache_value;
2382
2383 6556197 void cache_tile_mod_clear()
2384 {
2385 6556197 tilemod_cache_state = {false};
2386 6556197 }
2387
2388 12778724 int32_t item_tile_mod()
2389 {
2390 51114896 tilemod_cache_state_t state = {
2391 .valid = true,
2392 12778724 .bunny_clock = Hero.BunnyClock() != 0,
2393 12778724 .superman = Hero.superman,
2394 12778724 .shield = Hero.active_shield_id,
2395 };
2396
2/2
✓ Branch 0 taken 8414911 times.
✓ Branch 1 taken 4363813 times.
12778724 if (tilemod_cache_state == state)
2397 8414911 return tilemod_cache_value;
2398
2399 4363813 int32_t tile=0;
2400 4363813 bool check_bombcost = !get_qr(qr_BROKEN_BOMB_AMMO_COSTS);
2401
4/4
✓ Branch 0 taken 3950576 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 3031297 times.
✓ Branch 3 taken 919279 times.
4363813 if(check_bombcost || game->get_bombs())
2402 {
2403 3444534 int32_t itemid = current_item_id(itype_bomb,check_bombcost);
2404
3/4
✓ Branch 0 taken 3385067 times.
✓ Branch 1 taken 59467 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3385067 times.
3444534 if(itemid > -1 && checkbunny(itemid))
2405 3385067 tile+=itemsbuf[itemid].ltm;
2406 3444534 }
2407
2408
4/4
✓ Branch 0 taken 3950576 times.
✓ Branch 1 taken 413237 times.
✓ Branch 2 taken 928295 times.
✓ Branch 3 taken 3022281 times.
4363813 if(check_bombcost || game->get_sbombs())
2409 {
2410 1341532 int32_t itemid = current_item_id(itype_sbomb,check_bombcost);
2411
3/4
✓ Branch 0 taken 928054 times.
✓ Branch 1 taken 413478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 928054 times.
1341532 if(itemid > -1 && checkbunny(itemid))
2412 928054 tile+=itemsbuf[itemid].ltm;
2413 1341532 }
2414
2415
2/2
✓ Branch 0 taken 4359214 times.
✓ Branch 1 taken 4599 times.
4363813 if(current_item(itype_clock))
2416 {
2417 4599 int32_t itemid =
2418
2/2
✓ Branch 0 taken 4594 times.
✓ Branch 1 taken 5 times.
4599 get_qr(qr_HARDCODED_LITEM_LTMS)
2419 ? iClock
2420 5 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2421
2/4
✓ Branch 0 taken 4599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4599 times.
4599 if(itemid > -1 && checkbunny(itemid))
2422 4599 tile+=itemsbuf[itemid].ltm;
2423 4599 }
2424
2425
2/2
✓ Branch 0 taken 3755172 times.
✓ Branch 1 taken 608641 times.
4363813 if(current_item(itype_key))
2426 {
2427 608641 int32_t itemid =
2428
1/2
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
608641 get_qr(qr_HARDCODED_LITEM_LTMS)
2429 ? iKey
2430 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2431
2/4
✓ Branch 0 taken 608641 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 608641 times.
608641 if(itemid > -1 && checkbunny(itemid))
2432 608641 tile+=itemsbuf[itemid].ltm;
2433 608641 }
2434
2435
2/2
✓ Branch 0 taken 3862953 times.
✓ Branch 1 taken 500860 times.
4363813 if(current_item(itype_lkey))
2436 {
2437 500860 int32_t itemid =
2438
2/2
✓ Branch 0 taken 414146 times.
✓ Branch 1 taken 86714 times.
500860 get_qr(qr_HARDCODED_LITEM_LTMS)
2439 ? iLevelKey
2440 86714 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2441
2/4
✓ Branch 0 taken 500860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500860 times.
500860 if(itemid > -1 && checkbunny(itemid))
2442 500860 tile+=itemsbuf[itemid].ltm;
2443 500860 }
2444
2445
2/2
✓ Branch 0 taken 1529344 times.
✓ Branch 1 taken 2834469 times.
4363813 if(current_item(itype_map))
2446 {
2447 2834469 int32_t itemid =
2448
2/2
✓ Branch 0 taken 2823835 times.
✓ Branch 1 taken 10634 times.
2834469 get_qr(qr_HARDCODED_LITEM_LTMS)
2449 ? iMap
2450 10634 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2451
2/4
✓ Branch 0 taken 2834469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2834469 times.
2834469 if(itemid > -1 && checkbunny(itemid))
2452 2834469 tile+=itemsbuf[itemid].ltm;
2453 2834469 }
2454
2455
2/2
✓ Branch 0 taken 2051823 times.
✓ Branch 1 taken 2311990 times.
4363813 if(current_item(itype_compass))
2456 {
2457 2311990 int32_t itemid =
2458
2/2
✓ Branch 0 taken 2295942 times.
✓ Branch 1 taken 16048 times.
2311990 get_qr(qr_HARDCODED_LITEM_LTMS)
2459 ? iCompass
2460 16048 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2461
2/4
✓ Branch 0 taken 2311990 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2311990 times.
2311990 if(itemid > -1 && checkbunny(itemid))
2462 2311990 tile+=itemsbuf[itemid].ltm;
2463 2311990 }
2464
2465
2/2
✓ Branch 0 taken 1277397 times.
✓ Branch 1 taken 3086416 times.
4363813 if(current_item(itype_bosskey))
2466 {
2467 3086416 int32_t itemid =
2468
2/2
✓ Branch 0 taken 2993139 times.
✓ Branch 1 taken 93277 times.
3086416 get_qr(qr_HARDCODED_LITEM_LTMS)
2469 ? iBossKey
2470 93277 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2471
2/4
✓ Branch 0 taken 3086416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3086416 times.
3086416 if(itemid > -1 && checkbunny(itemid))
2472 3086416 tile+=itemsbuf[itemid].ltm;
2473 3086416 }
2474
2475
2/2
✓ Branch 0 taken 48263 times.
✓ Branch 1 taken 4315550 times.
4363813 if(current_item(itype_magiccontainer))
2476 {
2477 4315550 int32_t itemid =
2478
2/2
✓ Branch 0 taken 3884757 times.
✓ Branch 1 taken 430793 times.
4315550 get_qr(qr_HARDCODED_LITEM_LTMS)
2479 ? iMagicC
2480 430793 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2481
3/4
✓ Branch 0 taken 4315550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 4315533 times.
4315550 if(itemid > -1 && checkbunny(itemid))
2482 4315533 tile+=itemsbuf[itemid].ltm;
2483 4315550 }
2484
2485
2/2
✓ Branch 0 taken 1294626 times.
✓ Branch 1 taken 3069187 times.
4363813 if(current_item(itype_triforcepiece))
2486 {
2487 3069187 int32_t itemid =
2488
1/2
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
3069187 get_qr(qr_HARDCODED_LITEM_LTMS)
2489 ? iTriforce
2490 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2491
2/4
✓ Branch 0 taken 3069187 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3069187 times.
3069187 if(itemid > -1 && checkbunny(itemid))
2492 3069187 tile+=itemsbuf[itemid].ltm;
2493 3069187 }
2494
2495
2/2
✓ Branch 0 taken 2234272256 times.
✓ Branch 1 taken 4363813 times.
2238636069 for(int32_t i=0; i<itype_max; i++)
2496 {
2497
2/2
✓ Branch 0 taken 2013598720 times.
✓ Branch 1 taken 220673536 times.
2234272256 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2498 {
2499
2/2
✓ Branch 0 taken 4310030 times.
✓ Branch 1 taken 216363506 times.
220673536 switch(i)
2500 {
2501 case itype_bomb:
2502 case itype_sbomb:
2503 case itype_clock:
2504 case itype_key:
2505 case itype_lkey:
2506 case itype_map:
2507 case itype_compass:
2508 case itype_bosskey:
2509 case itype_magiccontainer:
2510 case itype_triforcepiece:
2511 4310030 continue; //already handled
2512 }
2513 216363506 }
2514 2229962226 int32_t itemid = current_item_id(i,false);
2515
2/2
✓ Branch 0 taken 2225598413 times.
✓ Branch 1 taken 4363813 times.
2229962226 if(i == itype_shield)
2516 4363813 itemid = getCurrentShield(false);
2517
2518
4/4
✓ Branch 0 taken 113997009 times.
✓ Branch 1 taken 2115965217 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 113997008 times.
2229962226 if(itemid < 0 || !checkbunny(itemid))
2519 2115965218 continue;
2520
2521 113997008 itemdata const& itm = itemsbuf[itemid];
2522
2523
2/2
✓ Branch 0 taken 110334385 times.
✓ Branch 1 taken 3662623 times.
113997008 switch(itm.family)
2524 {
2525 case itype_shield:
2526
1/2
✓ Branch 0 taken 3662623 times.
✗ Branch 1 not taken.
3662623 if(itm.flags & ITEM_FLAG9) //active shield
2527 {
2528 if(!usingActiveShield(itemid))
2529 {
2530 tile+=itm.misc6; //'Inactive PTM'
2531 continue;
2532 }
2533 }
2534 3662623 break;
2535 }
2536
2537 113997008 tile+=itm.ltm;
2538 113997008 }
2539
2540 4363813 tilemod_cache_value = tile;
2541 4363813 tilemod_cache_state = state;
2542 4363813 return tile;
2543 12778724 }
2544
2545 12778724 int32_t bunny_tile_mod()
2546 {
2547
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 12776854 times.
12778724 if(Hero.BunnyClock())
2548 {
2549 1870 return game->get_bunny_ltm();
2550 }
2551 12776854 return 0;
2552 12778724 }
2553
2554 // Hints are drawn on a separate layer to combo reveals.
2555 20010 void draw_lens_under(BITMAP *dest, bool layer)
2556 {
2557 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2558 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2559 //Lens flag 3: Don't show armos/chest/dive items
2560 //Lens flag 4: Show Raft Paths
2561 //Lens flag 5: Show Invisible Enemies
2562
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 19554 times.
✓ Branch 2 taken 9777 times.
✓ Branch 3 taken 9777 times.
20010 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2563
2564 20010 int32_t strike_hint_table[11]=
2565 {
2566 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2567 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2568 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2569 };
2570
2571 // int32_t page = tmpscr->cpage;
2572 {
2573 20010 int32_t blink_rate=flash_reduction_enabled()?6:1;
2574 // int32_t temptimer=0;
2575 20010 int32_t tempitem, tempweapon=0;
2576 20010 strike_hint=strike_hint_table[strike_hint_counter];
2577
2578
2/2
✓ Branch 0 taken 19412 times.
✓ Branch 1 taken 598 times.
20010 if(strike_hint_timer>32)
2579 {
2580 598 strike_hint_timer=0;
2581 598 strike_hint_counter=((strike_hint_counter+1)%11);
2582 598 }
2583
2584 20010 ++strike_hint_timer;
2585
2586
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 20010 times.
3541770 for(int32_t i=0; i<176; i++)
2587 {
2588 3521760 int32_t x = (i & 15) << 4;
2589 3521760 int32_t y = (i & 0xF0) + playing_field_offset;
2590 3521760 int32_t tempitemx=-16, tempitemy=-16;
2591 3521760 int32_t tempweaponx=-16, tempweapony=-16;
2592
2593
2/2
✓ Branch 0 taken 7043520 times.
✓ Branch 1 taken 3521760 times.
10565280 for(int32_t iter=0; iter<2; ++iter)
2594 {
2595 7043520 int32_t checkflag=0;
2596
2597
2/2
✓ Branch 0 taken 3521760 times.
✓ Branch 1 taken 3521760 times.
7043520 if(iter==0)
2598 {
2599 3521760 checkflag=combobuf[tmpscr->data[i]].flag;
2600 3521760 }
2601 else
2602 {
2603 3521760 checkflag=tmpscr->sflag[i];
2604 }
2605
2606
2/2
✓ Branch 0 taken 7042422 times.
✓ Branch 1 taken 1098 times.
7043520 if(checkflag==mfSTRIKE)
2607 {
2608
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2609 {
2610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2611 906 }
2612 else
2613 {
2614 192 checkflag = strike_hint;
2615 }
2616 1098 }
2617
2618
21/36
✓ Branch 0 taken 6894870 times.
✓ Branch 1 taken 3258 times.
✓ Branch 2 taken 108898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2602 times.
✓ Branch 5 taken 28750 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 93 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 25 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 138 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
7043520 switch(checkflag)
2619 {
2620 case 0:
2621 case mfZELDA:
2622 case mfPUSHED:
2623 case mfENEMY0:
2624 case mfENEMY1:
2625 case mfENEMY2:
2626 case mfENEMY3:
2627 case mfENEMY4:
2628 case mfENEMY5:
2629 case mfENEMY6:
2630 case mfENEMY7:
2631 case mfENEMY8:
2632 case mfENEMY9:
2633 case mfSINGLE:
2634 case mfSINGLE16:
2635 case mfNOENEMY:
2636 case mfTRAP_H:
2637 case mfTRAP_V:
2638 case mfTRAP_4:
2639 case mfTRAP_LR:
2640 case mfTRAP_UD:
2641 case mfNOGROUNDENEMY:
2642 case mfNOBLOCKS:
2643 case mfSCRIPT1:
2644 case mfSCRIPT2:
2645 case mfSCRIPT3:
2646 case mfSCRIPT4:
2647 case mfSCRIPT5:
2648 case mfSCRIPT6:
2649 case mfSCRIPT7:
2650 case mfSCRIPT8:
2651 case mfSCRIPT9:
2652 case mfSCRIPT10:
2653 case mfSCRIPT11:
2654 case mfSCRIPT12:
2655 case mfSCRIPT13:
2656 case mfSCRIPT14:
2657 case mfSCRIPT15:
2658 case mfSCRIPT16:
2659 case mfSCRIPT17:
2660 case mfSCRIPT18:
2661 case mfSCRIPT19:
2662 case mfSCRIPT20:
2663 case mfPITHOLE:
2664 case mfPITFALLFLOOR:
2665 case mfLAVA:
2666 case mfICE:
2667 case mfICEDAMAGE:
2668 case mfDAMAGE1:
2669 case mfDAMAGE2:
2670 case mfDAMAGE4:
2671 case mfDAMAGE8:
2672 case mfDAMAGE16:
2673 case mfDAMAGE32:
2674 case mfFREEZEALL:
2675 case mfFREZEALLANSFFCS:
2676 case mfFREEZEFFCSOLY:
2677 case mfSCRITPTW1TRIG:
2678 case mfSCRITPTW2TRIG:
2679 case mfSCRITPTW3TRIG:
2680 case mfSCRITPTW4TRIG:
2681 case mfSCRITPTW5TRIG:
2682 case mfSCRITPTW6TRIG:
2683 case mfSCRITPTW7TRIG:
2684 case mfSCRITPTW8TRIG:
2685 case mfSCRITPTW9TRIG:
2686 case mfSCRITPTW10TRIG:
2687 case mfTROWEL:
2688 case mfTROWELNEXT:
2689 case mfTROWELSPECIALITEM:
2690 case mfSLASHPOT:
2691 case mfLIFTPOT:
2692 case mfLIFTORSLASH:
2693 case mfLIFTROCK:
2694 case mfLIFTROCKHEAVY:
2695 case mfDROPITEM:
2696 case mfSPECIALITEM:
2697 case mfDROPKEY:
2698 case mfDROPLKEY:
2699 case mfDROPCOMPASS:
2700 case mfDROPMAP:
2701 case mfDROPBOSSKEY:
2702 case mfSPAWNNPC:
2703 case mfSWITCHHOOK:
2704 case mfSIDEVIEWLADDER:
2705 case mfSIDEVIEWPLATFORM:
2706 case mfNOENEMYSPAWN:
2707 case mfENEMYALL:
2708 case mfNOMIRROR:
2709 case mfUNSAFEGROUND:
2710 case mf168:
2711 case mf169:
2712 case mf170:
2713 case mf171:
2714 case mf172:
2715 case mf173:
2716 case mf174:
2717 case mf175:
2718 case mf176:
2719 case mf177:
2720 case mf178:
2721 case mf179:
2722 case mf180:
2723 case mf181:
2724 case mf182:
2725 case mf183:
2726 case mf184:
2727 case mf185:
2728 case mf186:
2729 case mf187:
2730 case mf188:
2731 case mf189:
2732 case mf190:
2733 case mf191:
2734 case mf192:
2735 case mf193:
2736 case mf194:
2737 case mf195:
2738 case mf196:
2739 case mf197:
2740 case mf198:
2741 case mf199:
2742 case mf200:
2743 case mf201:
2744 case mf202:
2745 case mf203:
2746 case mf204:
2747 case mf205:
2748 case mf206:
2749 case mf207:
2750 case mf208:
2751 case mf209:
2752 case mf210:
2753 case mf211:
2754 case mf212:
2755 case mf213:
2756 case mf214:
2757 case mf215:
2758 case mf216:
2759 case mf217:
2760 case mf218:
2761 case mf219:
2762 case mf220:
2763 case mf221:
2764 case mf222:
2765 case mf223:
2766 case mf224:
2767 case mf225:
2768 case mf226:
2769 case mf227:
2770 case mf228:
2771 case mf229:
2772 case mf230:
2773 case mf231:
2774 case mf232:
2775 case mf233:
2776 case mf234:
2777 case mf235:
2778 case mf236:
2779 case mf237:
2780 case mf238:
2781 case mf239:
2782 case mf240:
2783 case mf241:
2784 case mf242:
2785 case mf243:
2786 case mf244:
2787 case mf245:
2788 case mf246:
2789 case mf247:
2790 case mf248:
2791 case mf249:
2792 case mf250:
2793 case mf251:
2794 case mf252:
2795 case mf253:
2796 case mf254:
2797 case mfEXTENDED:
2798 6894870 break;
2799
2800 case mfPUSHUD:
2801 case mfPUSHLR:
2802 case mfPUSH4:
2803 case mfPUSHU:
2804 case mfPUSHD:
2805 case mfPUSHL:
2806 case mfPUSHR:
2807 case mfPUSHUDNS:
2808 case mfPUSHLRNS:
2809 case mfPUSH4NS:
2810 case mfPUSHUNS:
2811 case mfPUSHDNS:
2812 case mfPUSHLNS:
2813 case mfPUSHRNS:
2814 case mfPUSHUDINS:
2815 case mfPUSHLRINS:
2816 case mfPUSH4INS:
2817 case mfPUSHUINS:
2818 case mfPUSHDINS:
2819 case mfPUSHLINS:
2820 case mfPUSHRINS:
2821
3/4
✓ Branch 0 taken 1939 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
3258 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2822
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1939 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2823 {
2824 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2825 }
2826
2827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2828
3/6
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 738 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3258 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2829 {
2830
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 1032 times.
2520 if(hints)
2831 {
2832
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2833 {
2834 case cPUSH_HEAVY:
2835 case cPUSH_HW:
2836 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2837 72 tempitemx=x, tempitemy=y;
2838
2839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2840 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2841
2842 72 break;
2843
2844 case cPUSH_HEAVY2:
2845 case cPUSH_HW2:
2846 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2847 63 tempitemx=x, tempitemy=y;
2848
2849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2850 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2851
2852 63 break;
2853 }
2854 1032 }
2855 2520 }
2856
2857 3258 break;
2858
2859 case mfWHISTLE:
2860
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2861 {
2862 tempitem=getItemID(itemsbuf,itype_whistle,1);
2863
2864 if(tempitem<0) break;
2865
2866 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2867 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2868 {
2869 tempitemx=x;
2870 tempitemy=y;
2871 }
2872
2873 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2874 }
2875
2876 2418 break;
2877
2878 //Why is this here?
2879 case mfFAIRY:
2880 case mfMAGICFAIRY:
2881 case mfALLFAIRY:
2882 if(hints)
2883 {
2884 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2885
2886 if(tempitem < 0) break;
2887
2888 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2889 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2890 {
2891 tempitemx=x;
2892 tempitemy=y;
2893 }
2894
2895 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2896 }
2897
2898 break;
2899
2900 case mfANYFIRE:
2901
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2902 {
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2904 252 }
2905 else
2906 {
2907 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2908
2909
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2910
2911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2912
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2913 {
2914 189 tempitemx=x;
2915 189 tempitemy=y;
2916 189 }
2917
2918 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2919 }
2920
2921 504 break;
2922
2923 case mfSTRONGFIRE:
2924 if(!hints)
2925 {
2926 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2927 }
2928 else
2929 {
2930 tempitem=getItemID(itemsbuf,itype_candle,2);
2931
2932 if(tempitem<0) break;
2933
2934 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2935 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2936 {
2937 tempitemx=x;
2938 tempitemy=y;
2939 }
2940
2941 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2942 }
2943
2944 break;
2945
2946 case mfMAGICFIRE:
2947 if(!hints)
2948 {
2949 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2950 }
2951 else
2952 {
2953 tempitem=getItemID(itemsbuf,itype_wand,1);
2954
2955 if(tempitem<0) break;
2956
2957 tempweapon=wFire;
2958
2959 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2960 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2961 {
2962 tempitemx=x;
2963 tempitemy=y;
2964 }
2965 else
2966 {
2967 tempweaponx=x;
2968 tempweapony=y;
2969 }
2970
2971 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2972 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2973 }
2974
2975 break;
2976
2977 case mfDIVINEFIRE:
2978 if(!hints)
2979 {
2980 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2981 }
2982 else
2983 {
2984 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2985
2986 if(tempitem<0) break;
2987
2988 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2989 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2990 {
2991 tempitemx=x;
2992 tempitemy=y;
2993 }
2994
2995 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2996 }
2997
2998 break;
2999
3000 case mfARROW:
3001
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
3002 {
3003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
3004 732 }
3005 else
3006 {
3007 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
3008
3009
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
3010
3011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3012
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3013 {
3014 61 tempitemx=x;
3015 61 tempitemy=y;
3016 61 }
3017
3018 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3019 }
3020
3021 814 break;
3022
3023 case mfSARROW:
3024 if(!hints)
3025 {
3026 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3027 }
3028 else
3029 {
3030 tempitem=getItemID(itemsbuf,itype_arrow,2);
3031
3032 if(tempitem<0) break;
3033
3034 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3035 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3036 {
3037 tempitemx=x;
3038 tempitemy=y;
3039 }
3040
3041 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3042 }
3043
3044 break;
3045
3046 case mfGARROW:
3047 if(!hints)
3048 {
3049 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3050 }
3051 else
3052 {
3053 tempitem=getItemID(itemsbuf,itype_arrow,3);
3054
3055 if(tempitem<0) break;
3056
3057 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3058 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3059 {
3060 tempitemx=x;
3061 tempitemy=y;
3062 }
3063
3064 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3065 }
3066
3067 break;
3068
3069 case mfBOMB:
3070
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 76 times.
93 if(!hints)
3071 {
3072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3073 76 }
3074 else
3075 {
3076 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3077 17 tempweapon = wLitBomb;
3078
3079 //if (tempitem<0) break;
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3081
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3082 {
3083 12 tempweaponx=x;
3084 12 tempweapony=y;
3085 12 }
3086
3087 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3088 }
3089
3090 93 break;
3091
3092 case mfSBOMB:
3093
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3094 {
3095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3096 48 }
3097 else
3098 {
3099 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3100 //if (tempitem<0) break;
3101 48 tempweapon = wLitSBomb;
3102
3103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3104
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3105 {
3106 36 tempweaponx=x;
3107 36 tempweapony=y;
3108 36 }
3109
3110 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3111 }
3112
3113 96 break;
3114
3115 case mfARMOS_SECRET:
3116
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3117 {
3118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3119 12 }
3120 24 break;
3121
3122 case mfBRANG:
3123
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if(!hints)
3124 {
3125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3126 20 }
3127 else
3128 {
3129 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3130
3131
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3132
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3134
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3135 {
3136 4 tempitemx=x;
3137 4 tempitemy=y;
3138 4 }
3139
3140 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3141 }
3142
3143 25 break;
3144
3145 case mfMBRANG:
3146 if(!hints)
3147 {
3148 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3149 }
3150 else
3151 {
3152 tempitem=getItemID(itemsbuf,itype_brang,2);
3153
3154 if(tempitem<0) break;
3155
3156 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3157 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3158 {
3159 tempitemx=x;
3160 tempitemy=y;
3161 }
3162
3163 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3164 }
3165
3166 break;
3167
3168 case mfFBRANG:
3169 if(!hints)
3170 {
3171 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3172 }
3173 else
3174 {
3175 tempitem=getItemID(itemsbuf,itype_brang,3);
3176
3177 if(tempitem<0) break;
3178
3179 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3180 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3181 {
3182 tempitemx=x;
3183 tempitemy=y;
3184 }
3185
3186 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3187 }
3188
3189 break;
3190
3191 case mfWANDMAGIC:
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!hints)
3193 {
3194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3195 138 }
3196 else
3197 {
3198 tempitem=getItemID(itemsbuf,itype_wand,1);
3199
3200 if(tempitem<0) break;
3201
3202 tempweapon=itemsbuf[tempitem].wpn3;
3203
3204 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3205 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3206 {
3207 tempitemx=x;
3208 tempitemy=y;
3209 }
3210 else
3211 {
3212 tempweaponx=x;
3213 tempweapony=y;
3214 --lens_hint_weapon[wMagic][4];
3215
3216 if(lens_hint_weapon[wMagic][4]<-8)
3217 {
3218 lens_hint_weapon[wMagic][4]=8;
3219 }
3220 }
3221
3222 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3223 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3224 }
3225
3226 138 break;
3227
3228 case mfREFMAGIC:
3229
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3230 {
3231 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3232 }
3233 else
3234 {
3235 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3236
3237
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3238
3239 16 tempweapon=ewMagic;
3240
3241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3242
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3243 {
3244 13 tempitemx=x;
3245 13 tempitemy=y;
3246 13 }
3247 else
3248 {
3249 3 tempweaponx=x;
3250 3 tempweapony=y;
3251
3252
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3253 {
3254 1 --lens_hint_weapon[ewMagic][4];
3255 1 }
3256 else
3257 {
3258 2 ++lens_hint_weapon[ewMagic][4];
3259 }
3260
3261
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3262 {
3263 lens_hint_weapon[ewMagic][2]=up;
3264 }
3265
3266
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3267 {
3268 2 lens_hint_weapon[ewMagic][2]=down;
3269 2 }
3270 }
3271
3272 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3273 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3274 }
3275
3276 16 break;
3277
3278 case mfREFFIREBALL:
3279
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3280 {
3281 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3282 }
3283 else
3284 {
3285 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3286
3287
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3288
3289 16 tempweapon=ewFireball;
3290
3291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3292
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3293 {
3294 12 tempitemx=x;
3295 12 tempitemy=y;
3296 12 tempweaponx=x;
3297 12 tempweapony=y;
3298 12 ++lens_hint_weapon[ewFireball][3];
3299
3300
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3301 {
3302 1 lens_hint_weapon[ewFireball][3]=-8;
3303 1 lens_hint_weapon[ewFireball][4]=8;
3304 1 }
3305
3306
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3307 {
3308 8 ++lens_hint_weapon[ewFireball][4];
3309 8 }
3310 else
3311 {
3312 4 --lens_hint_weapon[ewFireball][4];
3313 }
3314 12 }
3315
3316 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3317 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3318 }
3319
3320 16 break;
3321
3322 case mfSWORD:
3323
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3324 {
3325 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3326 }
3327 else
3328 {
3329 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3330
3331
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3332
3333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3334
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3335 {
3336 5 tempitemx=x;
3337 5 tempitemy=y;
3338 5 }
3339
3340 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3341 }
3342
3343 7 break;
3344
3345 case mfWSWORD:
3346 if(!hints)
3347 {
3348 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3349 }
3350 else
3351 {
3352 tempitem=getItemID(itemsbuf,itype_sword,2);
3353
3354 if(tempitem<0) break;
3355
3356 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3357 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3358 {
3359 tempitemx=x;
3360 tempitemy=y;
3361 }
3362
3363 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3364 }
3365
3366 break;
3367
3368 case mfMSWORD:
3369 if(!hints)
3370 {
3371 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3372 }
3373 else
3374 {
3375 tempitem=getItemID(itemsbuf,itype_sword,3);
3376
3377 if(tempitem<0) break;
3378
3379 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3380 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3381 {
3382 tempitemx=x;
3383 tempitemy=y;
3384 }
3385
3386 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3387 }
3388
3389 break;
3390
3391 case mfXSWORD:
3392 if(!hints)
3393 {
3394 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3395 }
3396 else
3397 {
3398 tempitem=getItemID(itemsbuf,itype_sword,4);
3399
3400 if(tempitem<0) break;
3401
3402 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3403 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3404 {
3405 tempitemx=x;
3406 tempitemy=y;
3407 }
3408
3409 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3410 }
3411
3412 break;
3413
3414 case mfSWORDBEAM:
3415
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3416 {
3417 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3418 }
3419 else
3420 {
3421 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3422
3423
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3424
3425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3426
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3427 {
3428 11 tempitemx=x;
3429 11 tempitemy=y;
3430 11 }
3431
3432 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3433 }
3434
3435 16 break;
3436
3437 case mfWSWORDBEAM:
3438 if(!hints)
3439 {
3440 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3441 }
3442 else
3443 {
3444 tempitem=getItemID(itemsbuf,itype_sword,2);
3445
3446 if(tempitem<0) break;
3447
3448 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3449 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3450 {
3451 tempitemx=x;
3452 tempitemy=y;
3453 }
3454
3455 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3456 }
3457
3458 break;
3459
3460 case mfMSWORDBEAM:
3461 if(!hints)
3462 {
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3464 }
3465 else
3466 {
3467 tempitem=getItemID(itemsbuf,itype_sword,3);
3468
3469 if(tempitem<0) break;
3470
3471 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3472 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3473 {
3474 tempitemx=x;
3475 tempitemy=y;
3476 }
3477
3478 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3479 }
3480
3481 break;
3482
3483 case mfXSWORDBEAM:
3484 if(!hints)
3485 {
3486 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3487 }
3488 else
3489 {
3490 tempitem=getItemID(itemsbuf,itype_sword,4);
3491
3492 if(tempitem<0) break;
3493
3494 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3495 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3496 {
3497 tempitemx=x;
3498 tempitemy=y;
3499 }
3500
3501 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3502 }
3503
3504 break;
3505
3506 case mfHOOKSHOT:
3507
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3508 {
3509 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3510 }
3511 else
3512 {
3513 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3514
3515
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3516
3517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3518
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3519 {
3520 12 tempitemx=x;
3521 12 tempitemy=y;
3522 12 }
3523
3524 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3525 }
3526
3527 17 break;
3528
3529 case mfWAND:
3530
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3531 {
3532 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3533 }
3534 else
3535 {
3536 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3537
3538
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3539
3540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3541
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3542 {
3543 28 tempitemx=x;
3544 28 tempitemy=y;
3545 28 }
3546
3547 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3548 }
3549
3550 35 break;
3551
3552 case mfHAMMER:
3553
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3554 {
3555 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3556 }
3557 else
3558 {
3559 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3560
3561
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3562
3563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3564
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3565 {
3566 13 tempitemx=x;
3567 13 tempitemy=y;
3568 13 }
3569
3570 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3571 }
3572
3573 17 break;
3574
3575 case mfARMOS_ITEM:
3576 case mfDIVE_ITEM:
3577
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2602 times.
2602 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3578 {
3579 2602 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3580 2602 }
3581 2602 break;
3582
3583 case 16:
3584 case 17:
3585 case 18:
3586 case 19:
3587 case 20:
3588 case 21:
3589 case 22:
3590 case 23:
3591 case 24:
3592 case 25:
3593 case 26:
3594 case 27:
3595 case 28:
3596 case 29:
3597 case 30:
3598 case 31:
3599
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 107890 times.
108898 if(!hints)
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107890 times.
215780 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3601 107890 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3602
3603 108898 break;
3604 case mfSECRETSNEXT:
3605 if(!hints)
3606 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3607 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3608
3609 break;
3610
3611 case mfSTRIKE:
3612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3613 {
3614 906 goto special;
3615 }
3616 else
3617 {
3618 break;
3619 }
3620
3621 28750 default: goto special;
3622
3623 special:
3624
8/8
✓ Branch 0 taken 14732 times.
✓ Branch 1 taken 14924 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 496 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29656 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3625 {
3626
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6604 times.
✓ Branch 2 taken 4954 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1650 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6604 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3627 {
3628 4954 rectfill(dest,x,y,x+15,y+15,WHITE);
3629 4954 }
3630 6604 }
3631
3632 29656 break;
3633 }
3634 7043520 }
3635 3521760 }
3636
3637
2/2
✓ Branch 0 taken 10005 times.
✓ Branch 1 taken 10005 times.
20010 if(layer)
3638 {
3639
2/2
✓ Branch 0 taken 9646 times.
✓ Branch 1 taken 359 times.
10005 if(tmpscr->door[0]==dWALK)
3640 359 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3641
3642
2/2
✓ Branch 0 taken 9582 times.
✓ Branch 1 taken 423 times.
10005 if(tmpscr->door[1]==dWALK)
3643 423 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3644
3645
2/2
✓ Branch 0 taken 9423 times.
✓ Branch 1 taken 582 times.
10005 if(tmpscr->door[2]==dWALK)
3646 582 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3647
3648
2/2
✓ Branch 0 taken 9381 times.
✓ Branch 1 taken 624 times.
10005 if(tmpscr->door[3]==dWALK)
3649 624 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3650
3651
2/2
✓ Branch 0 taken 9962 times.
✓ Branch 1 taken 43 times.
10005 if(tmpscr->door[0]==dBOMB)
3652 {
3653 43 showbombeddoor(dest, 0);
3654 43 }
3655
3656
2/2
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 39 times.
10005 if(tmpscr->door[1]==dBOMB)
3657 {
3658 39 showbombeddoor(dest, 1);
3659 39 }
3660
3661
2/2
✓ Branch 0 taken 9999 times.
✓ Branch 1 taken 6 times.
10005 if(tmpscr->door[2]==dBOMB)
3662 {
3663 6 showbombeddoor(dest, 2);
3664 6 }
3665
3666
2/2
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 37 times.
10005 if(tmpscr->door[3]==dBOMB)
3667 {
3668 37 showbombeddoor(dest, 3);
3669 37 }
3670 10005 }
3671
3672
2/2
✓ Branch 0 taken 17976 times.
✓ Branch 1 taken 2034 times.
20010 if(tmpscr->stairx + tmpscr->stairy)
3673 {
3674
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3675 {
3676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3677 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3678 1123 }
3679 else
3680 {
3681
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3682 {
3683 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3684 48 int32_t tempitemx=-16;
3685 48 int32_t tempitemy=-16;
3686
3687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3688
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3689 {
3690 24 tempitemx=tmpscr->stairx;
3691 24 tempitemy=tmpscr->stairy+playing_field_offset;
3692 24 }
3693
3694 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3695 48 }
3696 }
3697 2034 }
3698 }
3699 20010 }
3700
3701 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3702
3703 9666 void draw_lens_over()
3704 {
3705 // Oh, what the heck.
3706 static BITMAP *lens_scr = NULL;
3707 static int32_t last_width = -1;
3708 9666 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3709
3710 // Only redraw the circle if the size has changed
3711
2/2
✓ Branch 0 taken 9647 times.
✓ Branch 1 taken 19 times.
9666 if(width != last_width)
3712 {
3713
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(lens_scr == NULL)
3714 {
3715 17 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3716 17 }
3717
3718 19 clear_to_color(lens_scr, BLACK);
3719 19 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3720 19 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3721 19 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3722 19 last_width=width;
3723 19 }
3724
3725 9666 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3726 9666 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3727 9666 }
3728
3729 //----------------------------------------------------------------
3730
3731 31797 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3732 {
3733 //recreating a big bitmap every frame is highly sluggish.
3734
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
31797 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3735 31797 clear_to_color(wavebuf, BLACK);
3736 31797 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3737
3738 int32_t ofs;
3739 // int32_t amplitude=8;
3740 // int32_t wavelength=4;
3741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31797 times.
31797 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3742
4/6
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
✓ Branch 4 taken 494 times.
✓ Branch 5 taken 31303 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3743 31797 int32_t amp2=168;
3744
2/4
✓ Branch 0 taken 31797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31797 times.
31797 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3745 31797 int32_t i=frame%amp2;
3746
3747
2/2
✓ Branch 0 taken 5341896 times.
✓ Branch 1 taken 31797 times.
5373693 for(int32_t j=0; j<168; j++)
3748 {
3749
3/4
✓ Branch 0 taken 2670948 times.
✓ Branch 1 taken 2670948 times.
✓ Branch 2 taken 2670948 times.
✗ Branch 3 not taken.
5341896 if(j&1 && interpol)
3750 {
3751 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3752 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3753 }
3754 else
3755 {
3756 5341896 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3757 }
3758
3759
1/2
✓ Branch 0 taken 5341896 times.
✗ Branch 1 not taken.
5341896 if(ofs)
3760 {
3761
2/2
✓ Branch 0 taken 1367525376 times.
✓ Branch 1 taken 5341896 times.
1372867272 for(int32_t k=0; k<256; k++)
3762 {
3763 1367525376 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3764 1367525376 }
3765 5341896 }
3766 5341896 }
3767 31797 }
3768
3769 28224 void draw_fuzzy(int32_t fuzz)
3770 // draws from right half of scrollbuf to framebuf
3771 {
3772 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3773 byte *start, *si, *di;
3774
3775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(fuzz<1)
3776 fuzz = 1;
3777
3778 28224 xstep = 128%fuzz;
3779
3780
2/2
✓ Branch 0 taken 5880 times.
✓ Branch 1 taken 22344 times.
28224 if(xstep > 0)
3781 22344 xstep = fuzz-xstep;
3782
3783 28224 ystep = 112%fuzz;
3784
3785
2/2
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 19992 times.
28224 if(ystep > 0)
3786 19992 ystep = fuzz-ystep;
3787
3788 28224 firsty = 1;
3789
3790
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 1018416 times.
1046640 for(y=0; y<224;)
3791 {
3792 1018416 start = &(scrollbuf->line[y][256]);
3793
3794
4/4
✓ Branch 0 taken 1004304 times.
✓ Branch 1 taken 6336288 times.
✓ Branch 2 taken 6322176 times.
✓ Branch 3 taken 1018416 times.
7340592 for(dy=0; dy<ystep && dy+y<224; dy++)
3795 {
3796 6322176 si = start;
3797 6322176 di = &(framebuf->line[y+dy][0]);
3798 6322176 i = xstep;
3799 6322176 firstx = 1;
3800
3801
2/2
✓ Branch 0 taken 1618477056 times.
✓ Branch 1 taken 6322176 times.
1624799232 for(dx=0; dx<256; dx++)
3802 {
3803 1618477056 *(di++) = *si;
3804
3805
2/2
✓ Branch 0 taken 1363746048 times.
✓ Branch 1 taken 254731008 times.
1618477056 if(++i >= fuzz)
3806 {
3807
2/2
✓ Branch 0 taken 248408832 times.
✓ Branch 1 taken 6322176 times.
254731008 if(!firstx)
3808 248408832 si += fuzz;
3809 else
3810 {
3811 6322176 si += fuzz-xstep;
3812 6322176 firstx = 0;
3813 }
3814
3815 254731008 i = 0;
3816 254731008 }
3817 1618477056 }
3818 6322176 }
3819
3820
2/2
✓ Branch 0 taken 990192 times.
✓ Branch 1 taken 28224 times.
1018416 if(!firsty)
3821 990192 y += fuzz;
3822 else
3823 {
3824 28224 y += ystep;
3825 28224 ystep = fuzz;
3826 28224 firsty = 0;
3827 }
3828 }
3829 28224 }
3830
3831 18319553 void updatescr(bool allowwavy)
3832 {
3833
4/6
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 18319291 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
✓ Branch 4 taken 262 times.
✗ Branch 5 not taken.
18319553 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3834
4/6
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 18319291 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 262 times.
18319553 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3835
3836
2/2
✓ Branch 0 taken 18292561 times.
✓ Branch 1 taken 26992 times.
18319553 if(toogam)
3837 {
3838 26992 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3839 26992 }
3840
3841
1/2
✓ Branch 0 taken 18319553 times.
✗ Branch 1 not taken.
18319553 if(Showpal)
3842 dump_pal(framebuf);
3843
3844
2/2
✓ Branch 0 taken 17806244 times.
✓ Branch 1 taken 513309 times.
18319553 if(!Playing)
3845 513309 black_opening_count=0;
3846
3847
2/2
✓ Branch 0 taken 18155134 times.
✓ Branch 1 taken 164419 times.
18319553 if(black_opening_count<0) //shape is opening up
3848 {
3849 164419 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3850
3851
2/4
✓ Branch 0 taken 164419 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 164419 times.
164419 if(Advance||(!Paused))
3852 {
3853 164419 ++black_opening_count;
3854 164419 }
3855 164419 }
3856
2/2
✓ Branch 0 taken 18107152 times.
✓ Branch 1 taken 47982 times.
18155134 else if(black_opening_count>0) //shape is closing
3857 {
3858 47982 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3859
3860
2/4
✓ Branch 0 taken 47982 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47982 times.
47982 if(Advance||(!Paused))
3861 {
3862 47982 --black_opening_count;
3863 47982 }
3864 47982 }
3865
3866
3/4
✓ Branch 0 taken 18110370 times.
✓ Branch 1 taken 209183 times.
✓ Branch 2 taken 18110370 times.
✗ Branch 3 not taken.
18319553 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3867 {
3868 black_opening_shape = bosCIRCLE;
3869 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3870 refreshTints();
3871 refreshpal=true;
3872 }
3873
3874
2/2
✓ Branch 0 taken 17691314 times.
✓ Branch 1 taken 628239 times.
18319553 if(refreshpal)
3875 {
3876 628239 refreshpal=false;
3877 628239 RAMpal[253] = _RGB(0,0,0);
3878 628239 RAMpal[254] = _RGB(63,63,63);
3879 628239 hw_palette = &RAMpal;
3880 628239 update_hw_pal = true;
3881
3882 628239 create_rgb_table(&rgb_table, RAMpal, NULL);
3883 628239 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3884 628239 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3885
3886
2/2
✓ Branch 0 taken 160829184 times.
✓ Branch 1 taken 628239 times.
161457423 for(int32_t q=0; q<PAL_SIZE; q++)
3887 {
3888 160829184 trans_table2.data[0][q] = q;
3889 160829184 trans_table2.data[q][q] = q;
3890 160829184 }
3891 628239 }
3892
3893 18319553 bool clearwavy = (wavy <= 0);
3894
3895
2/2
✓ Branch 0 taken 8341 times.
✓ Branch 1 taken 18311212 times.
18319553 if(wavy <= 0)
3896 {
3897 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3898 18311212 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3899 18311212 }
3900
3901 18319553 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3902
3903
6/6
✓ Branch 0 taken 32047 times.
✓ Branch 1 taken 18287506 times.
✓ Branch 2 taken 31925 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31797 times.
18319553 if(wavy && Playing && allowwavy)
3904 {
3905 31797 draw_wavy(framebuf, wavybuf, wavy,false);
3906 31797 }
3907
3908
2/2
✓ Branch 0 taken 18311212 times.
✓ Branch 1 taken 8341 times.
18319553 if(clearwavy)
3909 18311212 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3910
2/4
✓ Branch 0 taken 8341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8341 times.
8341 else if(Playing && !Paused)
3911 8341 wavy--; // Wavy was set by a script. Decrement it.
3912
3913
5/6
✓ Branch 0 taken 17806244 times.
✓ Branch 1 taken 513309 times.
✓ Branch 2 taken 664395 times.
✓ Branch 3 taken 17141849 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 664395 times.
18319553 if(Playing && msgpos && !screenscrolling)
3914 {
3915
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_bg_display_buf->clip))
3916 664395 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3917
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_portrait_display_buf->clip))
3918 664395 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3919
1/2
✓ Branch 0 taken 664395 times.
✗ Branch 1 not taken.
664395 if(!(msg_txt_display_buf->clip))
3920 664395 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3921 664395 }
3922
3923 /*
3924 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3925 {
3926 BITMAP* subBmp = 0;
3927 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3928 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3929 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3930 destroy_bitmap(subBmp);
3931 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3932 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3933 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3934 }
3935 */
3936
3937
2/2
✓ Branch 0 taken 18133044 times.
✓ Branch 1 taken 186509 times.
18319553 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3938
3939
2/2
✓ Branch 0 taken 18138317 times.
✓ Branch 1 taken 181236 times.
18319553 if(nosubscr)
3940 {
3941 181236 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3942 181236 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3943 181236 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3944 181236 }
3945
3946 //TODO: Optimize blit 'overcalls' -Gleeok
3947
2/2
✓ Branch 0 taken 181236 times.
✓ Branch 1 taken 18138317 times.
18319553 BITMAP *source = nosubscr ? panorama : wavybuf;
3948 18319553 blit(source,framebuf,0,0,0,0,256,224);
3949
3950 18319553 update_hw_screen();
3951 18319553 }
3952
3953 //----------------------------------------------------------------
3954
3955 static PALETTE syspal;
3956 int32_t onGUISnapshot()
3957 {
3958 char buf[200];
3959 int32_t num=0;
3960 do
3961 {
3962 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3963 }
3964 while(num<99999 && exists(buf));
3965
3966 if (!al_save_bitmap(buf, al_get_backbuffer(all_get_display())))
3967 InfoDialog("Error", "Failed to save snapshot").show();
3968
3969 return D_O_K;
3970 }
3971
3972 int32_t onNonGUISnapshot()
3973 {
3974 PALETTE temppal;
3975 get_palette(temppal);
3976 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3977
3978 char buf[200];
3979 int32_t num=0;
3980
3981 do
3982 {
3983 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3984 }
3985 while(num<99999 && exists(buf));
3986
3987 if ((tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET)) && !(key[KEY_ALT]))
3988 {
3989 BITMAP *b = create_bitmap_ex(8,256,168);
3990 clear_to_color(b,0);
3991 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3992 alleg4_save_bitmap(b, SnapshotScale, buf, realpal ? temppal : RAMpal);
3993 destroy_bitmap(b);
3994 }
3995 else
3996 {
3997 alleg4_save_bitmap(framebuf, SnapshotScale, buf, realpal?temppal:RAMpal);
3998 }
3999
4000 return D_O_K;
4001 }
4002
4003 int32_t onSnapshot()
4004 {
4005 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4006 {
4007 onGUISnapshot();
4008 }
4009 else
4010 {
4011 onNonGUISnapshot();
4012 }
4013
4014 return D_O_K;
4015 }
4016
4017 int32_t onSaveMapPic()
4018 {
4019 int32_t mapres2 = 0;
4020 char buf[200];
4021 int32_t num=0;
4022 mapscr tmpscr_b[2];
4023 mapscr tmpscr_c[6];
4024 BITMAP* _screen_draw_buffer = NULL;
4025 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4026 set_clip_state(_screen_draw_buffer,1);
4027
4028 for(int32_t i=0; i<6; ++i)
4029 {
4030 tmpscr_c[i] = tmpscr2[i];
4031 tmpscr2[i].zero_memory();
4032
4033 if(i>=2)
4034 {
4035 continue;
4036 }
4037
4038 tmpscr_b[i] = tmpscr[i];
4039 tmpscr[i].zero_memory();
4040 }
4041
4042 do
4043 {
4044 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4045 }
4046 while(num<99999 && exists(buf));
4047
4048 BITMAP* mappic = NULL;
4049
4050
4051 bool done=false, redraw=true;
4052
4053 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4054
4055 if(!mappic)
4056 {
4057 enter_sys_pal();
4058 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4059 exit_sys_pal();
4060 return D_O_K;;
4061 }
4062
4063 // draw the map
4064 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4065
4066 for(int32_t y=0; y<8; y++)
4067 {
4068 for(int32_t x=0; x<16; x++)
4069 {
4070 if(!displayOnMap(x, y))
4071 {
4072 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4073 }
4074 else
4075 {
4076 int32_t s = (y<<4) + x;
4077 loadscr2(1,s,-1);
4078
4079 for(int32_t i=0; i<6; i++)
4080 {
4081 if(tmpscr[1].layermap[i]<=0)
4082 continue;
4083
4084 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4085 }
4086
4087 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4088
4089 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4090
4091 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4092 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4093
4094 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4095
4096 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4097 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4098 {
4099 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4100 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4101 {
4102 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4103 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4104 }
4105 }
4106 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4107
4108 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4109
4110 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4111 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4112 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4113 {
4114 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4115 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4116 }
4117 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4118 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4119
4120 }
4121
4122 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4123 }
4124 }
4125
4126 for(int32_t i=0; i<6; ++i)
4127 {
4128 tmpscr2[i]=tmpscr_c[i];
4129
4130 if(i>=2)
4131 {
4132 continue;
4133 }
4134
4135 tmpscr[i]=tmpscr_b[i];
4136 }
4137
4138 save_bitmap(buf,mappic,RAMpal);
4139 destroy_bitmap(mappic);
4140 destroy_bitmap(_screen_draw_buffer);
4141 return D_O_K;
4142 }
4143
4144 61 void f_Quit(int32_t type)
4145 {
4146
2/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
61 if(type==qQUIT && !Playing)
4147 return;
4148
4149 61 bool from_menu = is_sys_pal;
4150
4151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4152 {
4153 61 music_pause();
4154 61 pause_all_sfx();
4155 61 sys_mouse();
4156 61 }
4157 61 enter_sys_pal();
4158 61 clear_keybuf();
4159
4160
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 13 times.
61 if (replay_version_check(0, 10))
4161 13 replay_poll();
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if (replay_is_replaying())
4163 61 replay_peek_quit();
4164
4165
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if (!replay_is_replaying())
4166 switch(type)
4167 {
4168 case qQUIT:
4169 onQuit();
4170 break;
4171
4172 case qRESET:
4173 onReset();
4174 break;
4175
4176 case qEXIT:
4177 onExit();
4178 break;
4179 }
4180
4181
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(Quit)
4182 {
4183 61 kill_sfx();
4184 61 music_stop();
4185 61 exit_sys_pal();
4186 61 update_hw_screen();
4187 61 }
4188 else
4189 {
4190 exit_sys_pal();
4191 if(!from_menu)
4192 {
4193 music_resume();
4194 resume_all_sfx();
4195 }
4196 }
4197
4198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!from_menu)
4199 61 game_mouse();
4200 61 eat_buttons();
4201
4202 61 zc_readrawkey(KEY_ESC);
4203
4204 61 zc_readrawkey(KEY_ENTER);
4205 61 }
4206
4207 //----------------------------------------------------------------
4208
4209 int32_t onNoWalls()
4210 {
4211 cheats_enqueue(Cheat::Walls);
4212 return D_O_K;
4213 }
4214
4215 int32_t onIgnoreSideview()
4216 {
4217 cheats_enqueue(Cheat::IgnoreSideView);
4218 return D_O_K;
4219 }
4220
4221 18318213 int32_t input_idle(bool checkmouse)
4222 {
4223 static int32_t mx, my, mz, mb;
4224
4225
4/6
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4908601 times.
✓ Branch 3 taken 13409612 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4908601 times.
23226814 if(keypressed() || zc_key_pressed() ||
4226
4/8
✓ Branch 0 taken 4908601 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4908601 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4908601 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4908601 times.
✗ Branch 7 not taken.
4908601 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4227 {
4228 13409612 idle_count = 0;
4229
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13409612 times.
13409612 if(active_count < MAX_ACTIVE)
4231 {
4232 13409612 ++active_count;
4233 13409612 }
4234 13409612 }
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4908601 times.
4908601 else if(idle_count < MAX_IDLE)
4236 {
4237 4908601 ++idle_count;
4238 4908601 active_count = 0;
4239 4908601 }
4240
4241 18318213 mx = mouse_x;
4242 18318213 my = mouse_y;
4243 18318213 mz = mouse_z;
4244 18318213 mb = mouse_b;
4245
4246 18318213 return idle_count;
4247 }
4248
4249 int32_t onGoFast()
4250 {
4251 cheats_enqueue(Cheat::Fast);
4252 return D_O_K;
4253 }
4254
4255 int32_t onKillCheat()
4256 {
4257 cheats_enqueue(Cheat::Kill);
4258 return D_O_K;
4259 }
4260
4261 int32_t onSecretsCheat()
4262 {
4263 cheats_enqueue(Cheat::TrigSecrets);
4264 return D_O_K;
4265 }
4266 int32_t onSecretsCheatPerm()
4267 {
4268 cheats_enqueue(Cheat::TrigSecretsPerm);
4269 return D_O_K;
4270 }
4271
4272 int32_t onShowLayer0()
4273 {
4274 show_layer_0 = !show_layer_0;
4275 return D_O_K;
4276 }
4277 int32_t onShowLayer1()
4278 {
4279 show_layer_1 = !show_layer_1;
4280 return D_O_K;
4281 }
4282 int32_t onShowLayer2()
4283 {
4284 show_layer_2 = !show_layer_2;
4285 return D_O_K;
4286 }
4287 int32_t onShowLayer3()
4288 {
4289 show_layer_3 = !show_layer_3;
4290 return D_O_K;
4291 }
4292 int32_t onShowLayer4()
4293 {
4294 show_layer_4 = !show_layer_4;
4295 return D_O_K;
4296 }
4297 int32_t onShowLayer5()
4298 {
4299 show_layer_5 = !show_layer_5;
4300 return D_O_K;
4301 }
4302 int32_t onShowLayer6()
4303 {
4304 show_layer_6 = !show_layer_6;
4305 return D_O_K;
4306 }
4307 int32_t onShowLayerO()
4308 {
4309 show_layer_over=!show_layer_over;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayerP()
4313 {
4314 show_layer_push=!show_layer_push;
4315 return D_O_K;
4316 }
4317 int32_t onShowLayerS()
4318 {
4319 show_sprites=!show_sprites;
4320 return D_O_K;
4321 }
4322 int32_t onShowLayerF()
4323 {
4324 show_ffcs=!show_ffcs;
4325 return D_O_K;
4326 }
4327 int32_t onShowLayerW()
4328 {
4329 show_walkflags=!show_walkflags;
4330 if(show_walkflags)
4331 show_effectflags = false;
4332 return D_O_K;
4333 }
4334 int32_t onShowLayerE()
4335 {
4336 show_effectflags=!show_effectflags;
4337 if(show_effectflags)
4338 show_walkflags = false;
4339 return D_O_K;
4340 }
4341 int32_t onShowFFScripts()
4342 {
4343 show_ff_scripts=!show_ff_scripts;
4344 return D_O_K;
4345 }
4346 int32_t onShowHitboxes()
4347 {
4348 show_hitboxes=!show_hitboxes;
4349 return D_O_K;
4350 }
4351 int32_t onShowInfoOpacity()
4352 {
4353 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4354 zc_set_config("zc","debug_info_opacity",info_opacity);
4355 return D_O_K;
4356 }
4357
4358 int32_t onLightSwitch()
4359 {
4360 cheats_enqueue(Cheat::Light);
4361 return D_O_K;
4362 }
4363
4364 int32_t onGoTo();
4365 int32_t onGoToComplete();
4366
4367 18318213 bool handle_close_btn_quit()
4368 {
4369
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(close_button_quit)
4370 {
4371 close_button_quit=false;
4372 f_Quit(qEXIT);
4373 }
4374 18318213 return (exiting_program = Quit==qEXIT);
4375 }
4376
4377 18318213 void syskeys()
4378 {
4379 18318213 update_system_keys();
4380
4381 int32_t oldtitle_version;
4382
4383 18318213 poll_joystick();
4384
4385 18318213 handle_close_btn_quit();
4386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
18318213 if(Quit == qEXIT) return;
4387
4388
2/10
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18318213 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18318213 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4389 {
4390 System();
4391 }
4392
4393 18318213 mouse_down=gui_mouse_b();
4394
4395
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(zc_read_system_key(KEY_F1))
4396 {
4397 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4398 {
4399 halt=!halt;
4400 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4401 }
4402 else
4403 {
4404 Throttlefps=!Throttlefps;
4405 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4406 }
4407 }
4408
4409
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(zc_read_system_key(KEY_F2))
4410 {
4411 ShowFPS=!ShowFPS;
4412 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4413 }
4414
4415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318213 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4416
4417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318213 if(zc_read_system_key(KEY_F4) && Playing)
4418 {
4419 Paused=true;
4420 Advance=true;
4421 }
4422
4423
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(zc_read_system_key(KEY_F6)) onTryQuit();
4424
4425 #ifndef ALLEGRO_MACOSX
4426
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4427
4428
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4429 #else
4430 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4431
4432 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4433 #endif
4434
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18318213 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4435
4436
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if (zc_read_system_key(KEY_F12))
4437 {
4438 onSnapshot();
4439 }
4440
4441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18318213 if(debug_enabled && zc_read_system_key(KEY_TAB))
4442 set_debug(!get_debug());
4443
4444
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(CheatModifierKeys())
4445 {
4446 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4447 {
4448 if(!bindable_cheat(c))
4449 continue;
4450 if(get_debug() || cheat >= cheat_lvl(c))
4451 {
4452 if(checkcheat(c))
4453 cheats_hit_bind(c);
4454 }
4455 }
4456 }
4457
4458
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(volkeys)
4459 {
4460 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4461
4462 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4463
4464 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4465
4466 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4467 }
4468
4469
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18318213 if(!get_debug() || !SystemKeys || replay_is_replaying())
4470 18318213 goto bottom;
4471
4472 if(zc_readkey(KEY_P)) Paused=!Paused;
4473
4474 //if(zc_readkey(KEY_P)) centerHero();
4475 if(zc_readkey(KEY_A))
4476 {
4477 Paused=true;
4478 Advance=true;
4479 }
4480
4481 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4482 #ifndef ALLEGRO_MACOSX
4483 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4484
4485 if(zc_readkey(KEY_F7))
4486 {
4487 Matrix(ss_speed, ss_density, 0);
4488 game_pal();
4489 }
4490 #else
4491 // The reason these are different on Mac in the first place is that
4492 // the OS doesn't let us use F9 and F10...
4493 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4494
4495 if(zc_readkey(KEY_F9))
4496 {
4497 Matrix(ss_speed, ss_density, 0);
4498 game_pal();
4499 }
4500 #endif
4501 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4502 {
4503 //change containers
4504 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4505 {
4506 //magic containers
4507 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4508 {
4509 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4510 }
4511 else
4512 {
4513 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4514 }
4515 }
4516 else
4517 {
4518 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4519 {
4520 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4521 }
4522 else
4523 {
4524 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4525 }
4526 }
4527 }
4528
4529 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4530 {
4531 //change containers
4532 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4533 {
4534 //magic containers
4535 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4536 {
4537 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4538 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4539 //heart containers
4540 }
4541 else
4542 {
4543 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4544 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4545 }
4546 }
4547 else
4548 {
4549 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4550 {
4551 game->set_magic(zc_max(game->get_magic()-1,0));
4552 }
4553 else
4554 {
4555 game->set_life(zc_max(game->get_life()-1,0));
4556 }
4557 }
4558 }
4559
4560 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4561
4562 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4563
4564 verifyBothWeapons();
4565
4566 bottom:
4567
4568
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(input_idle(true) > after_time())
4569 {
4570 Matrix(ss_speed, ss_density, 0);
4571 game_pal();
4572 }
4573 18318213 }
4574
4575 1125839 void checkQuitKeys()
4576 {
4577 #ifndef ALLEGRO_MACOSX
4578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1125839 times.
1125839 if(key[KEY_F9]) f_Quit(qRESET);
4579
4580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1125839 times.
1125839 if(key[KEY_F10]) f_Quit(qEXIT);
4581 #else
4582 if(key[KEY_F7]) f_Quit(qRESET);
4583
4584 if(key[KEY_F8]) f_Quit(qEXIT);
4585 #endif
4586 1125839 }
4587
4588 18318413 bool CheatModifierKeys()
4589 {
4590 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4591 // to trigger cheats.
4592
2/2
✓ Branch 0 taken 18318113 times.
✓ Branch 1 taken 300 times.
18318413 if (replay_is_replaying())
4593 18318113 return false;
4594
4595
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
300 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4596
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 100 times.
200 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4598 {
4599
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4600 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4601 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4602 {
4603 return true;
4604 }
4605 }
4606 100 return false;
4607 18318213 }
4608
4609 //99:05:54, for some reason?
4610 #define OLDMAXTIME 21405240
4611 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4612 #define MAXTIME 1944000000
4613
4614 18319553 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4615 {
4616
1/2
✓ Branch 0 taken 18319553 times.
✗ Branch 1 not taken.
18319553 if(zcmusic!=NULL)
4617 {
4618 zcmusic_poll();
4619 }
4620 18319553 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4621
4622 18319553 updatescr(allowwavy);
4623
4624 18319553 Advance=false;
4625
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18319553 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18319553 times.
18319553 while(Paused && !Advance && !Quit)
4626 {
4627 // have to call this, otherwise we'll get an infinite loop
4628 syskeys();
4629 if(allowF6Script)
4630 {
4631 FFCore.runF6Engine();
4632 }
4633 zc_throttle_fps();
4634
4635 #ifdef _WIN32
4636
4637 if(use_dwm_flush)
4638 {
4639 do_DwmFlush();
4640 }
4641
4642 #endif
4643
4644 // to keep music playing
4645 if(zcmusic!=NULL)
4646 {
4647 zcmusic_poll();
4648 }
4649
4650 update_hw_screen();
4651 }
4652
4653
2/2
✓ Branch 0 taken 18318255 times.
✓ Branch 1 taken 1298 times.
18319553 if(Quit)
4654 1298 return;
4655
4656
3/4
✓ Branch 0 taken 17805247 times.
✓ Branch 1 taken 513008 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17805247 times.
18318255 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4657 17805247 game->change_time(1);
4658
4659 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4660
4661 18318255 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4662
2/2
✓ Branch 0 taken 8607956 times.
✓ Branch 1 taken 9710299 times.
18318255 if (replay_version_check(0, 16))
4663 9710299 should_reset_down_state = replay_version_check(11, 16);
4664
2/2
✓ Branch 0 taken 14967988 times.
✓ Branch 1 taken 3350267 times.
18318255 if (should_reset_down_state)
4665 {
4666
2/2
✓ Branch 0 taken 60304806 times.
✓ Branch 1 taken 3350267 times.
63655073 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4667 60304806 down_control_states[i] = raw_control_state[i];
4668 3350267 }
4669
4670
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 18318213 times.
18318255 if (replay_is_active())
4671 {
4672
2/2
✓ Branch 0 taken 1545415 times.
✓ Branch 1 taken 16772798 times.
18318213 if (replay_version_check(3))
4673 16772798 replay_poll();
4674
4675
4/4
✓ Branch 0 taken 7389596 times.
✓ Branch 1 taken 10928617 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 7289061 times.
18318213 if (replay_version_check(11) || replay_version_check(6, 8))
4676 11029152 replay_peek_input();
4677 18318213 }
4678
4679 18318255 load_control_called_this_frame = false;
4680
4681 18318255 poll_keyboard();
4682 18318255 update_keys();
4683
4684 18318255 ++frame;
4685
4686
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 18318113 times.
18318255 if (replay_is_replaying())
4687 18318113 replay_do_cheats();
4688 18318255 syskeys();
4689
4690 // The mouse variables can change from the mouse thread at anytime during a frame,
4691 // so save the result at the start so that replaying is consistent.
4692 18318255 script_mouse_x = gui_mouse_x();
4693 18318255 script_mouse_y = gui_mouse_y();
4694 18318255 script_mouse_z = mouse_z;
4695 18318255 script_mouse_b = mouse_b;
4696
4697 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4698 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4699 // approach here means it doesn't matter which call adds the cheat.
4700 18318255 cheats_execute_queued();
4701
4702
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 18318113 times.
18318255 if (replay_is_replaying())
4703 18318113 replay_peek_quit();
4704
2/2
✓ Branch 0 taken 18318194 times.
✓ Branch 1 taken 61 times.
18318255 if (GameFlags & GAMEFLAG_TRYQUIT)
4705 61 replay_step_quit(0);
4706
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 18314563 times.
18318255 if(allowF6Script)
4707 18314563 FFCore.runF6Engine();
4708
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 18317517 times.
18318255 if (Quit)
4709 738 replay_step_quit(Quit);
4710 // Someday... maybe install a Turbo button here?
4711 18318255 zc_throttle_fps();
4712
4713 #ifdef _WIN32
4714
4715 if(use_dwm_flush)
4716 {
4717 do_DwmFlush();
4718 }
4719
4720 #endif
4721
4722 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4723
2/2
✓ Branch 0 taken 208650 times.
✓ Branch 1 taken 18109605 times.
18318255 if(sfxcleanup)
4724 18109605 sfx_cleanup();
4725
4726 18318255 jit_poll();
4727
4728 #ifdef __EMSCRIPTEN__
4729 // Yield the main thread back to the browser occasionally.
4730 if (is_headless())
4731 {
4732 static int rate = 10000;
4733 static int force_yield = rate;
4734 if (force_yield++ >= rate)
4735 {
4736 force_yield = 0;
4737 emscripten_sleep(0);
4738 }
4739 }
4740 #endif
4741
4742
4/6
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 18317999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 256 times.
✗ Branch 5 not taken.
18318255 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4743
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 18318155 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
18318255 if (zqtesting_mode && test_mode_auto_restart)
4744 {
4745 static auto last_write_time = fs::last_write_time(qstpath);
4746 static auto last_check = std::chrono::system_clock::now();
4747
4748 if (std::chrono::system_clock::now() - last_check > 200ms)
4749 {
4750 last_check = std::chrono::system_clock::now();
4751 auto write_time = fs::last_write_time(qstpath);
4752 if (last_write_time != write_time)
4753 {
4754 last_write_time = write_time;
4755 disableClickToFreeze = false;
4756 Quit = qRESET;
4757 replay_quit();
4758 }
4759 }
4760 }
4761 18319553 }
4762
4763 589 void zapout()
4764 {
4765 589 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4766 589 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4767
4768 589 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4769 589 script_drawing_commands.Clear();
4770
4771 // zap out
4772
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 14136 times.
14725 for(int32_t i=1; i<=24; i++)
4773 {
4774 14136 draw_fuzzy(i);
4775 14136 advanceframe(true);
4776
4777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14136 times.
14136 if(Quit)
4778 {
4779 break;
4780 }
4781 14136 }
4782 589 }
4783
4784 587 void zapin()
4785 {
4786 587 FFCore.warpScriptCheck();
4787 587 draw_screen(tmpscr);
4788 587 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4789 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4790 587 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4791
4792 // zap out
4793 587 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4794
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 14088 times.
14675 for(int32_t i=24; i>=1; i--)
4795 {
4796 14088 draw_fuzzy(i);
4797 14088 advanceframe(true);
4798
4799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14088 times.
14088 if(Quit)
4800 {
4801 break;
4802 }
4803 14088 }
4804 587 }
4805
4806
4807 235 void wavyout(bool showhero)
4808 {
4809 235 draw_screen(tmpscr, showhero);
4810 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4811
4812 235 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4813 235 clear_to_color(wavebuf,0);
4814 235 blit(framebuf,wavebuf,0,0,16,0,256,224);
4815
4816 static PALETTE wavepal;
4817
4818 int32_t ofs;
4819 235 int32_t amplitude=8;
4820
4821 235 int32_t wavelength=4;
4822 235 double palpos=0, palstep=4, palstop=126;
4823
4824 235 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4825
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 9845 times.
10079 for(int32_t i=0; i<168; i+=wavelength)
4826 {
4827
2/2
✓ Branch 0 taken 2520320 times.
✓ Branch 1 taken 9845 times.
2530165 for(int32_t l=0; l<256; l++)
4828 {
4829 2520320 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4830 2520320 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4831 2520320 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4832 2520320 }
4833
4834 9845 palpos+=palstep;
4835
4836
1/2
✓ Branch 0 taken 9845 times.
✗ Branch 1 not taken.
9845 if(palpos>=0)
4837 {
4838 9845 hw_palette = &wavepal;
4839 9845 update_hw_pal = true;
4840 9845 }
4841 else
4842 {
4843 hw_palette = &RAMpal;
4844 update_hw_pal = true;
4845 }
4846
4847
2/2
✓ Branch 0 taken 1653960 times.
✓ Branch 1 taken 9845 times.
1663805 for(int32_t j=0; j+playing_field_offset<224; j++)
4848 {
4849
2/2
✓ Branch 0 taken 423413760 times.
✓ Branch 1 taken 1653960 times.
425067720 for(int32_t k=0; k<256; k++)
4850 {
4851 423413760 ofs=0;
4852
4853
4/4
✓ Branch 0 taken 206448640 times.
✓ Branch 1 taken 216965120 times.
✓ Branch 2 taken 103224320 times.
✓ Branch 3 taken 103224320 times.
423413760 if((j<i)&&(j&1))
4854 {
4855 103224320 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4856 103224320 }
4857
4858 423413760 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4859 423413760 }
4860 1653960 }
4861
4862 9845 advanceframe(true);
4863
4864 // animate_combos();
4865
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9844 times.
9845 if(Quit)
4866 1 break;
4867 9844 }
4868
4869 235 destroy_bitmap(wavebuf);
4870 235 }
4871
4872 232 void wavyin()
4873 {
4874 232 draw_screen(tmpscr);
4875 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4876
4877 232 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4878 232 clear_to_color(wavebuf,0);
4879 232 blit(framebuf,wavebuf,0,0,16,0,256,224);
4880
4881 static PALETTE wavepal;
4882
4883 //Breaks dark rooms.
4884 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4885 /*
4886 loadfullpal();
4887 loadlvlpal(DMaps[currdmap].color);
4888 ringcolor(false);
4889 */
4890 232 refreshpal=false;
4891 int32_t ofs;
4892 232 int32_t amplitude=8;
4893 232 int32_t wavelength=4;
4894 232 double palpos=168, palstep=4, palstop=126;
4895
4896 232 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4897
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 9703 times.
9934 for(int32_t i=0; i<168; i+=wavelength)
4898 {
4899
2/2
✓ Branch 0 taken 2483968 times.
✓ Branch 1 taken 9703 times.
2493671 for(int32_t l=0; l<256; l++)
4900 {
4901 2483968 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4902 2483968 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4903 2483968 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4904 2483968 }
4905
4906 9703 palpos-=palstep;
4907
4908
1/2
✓ Branch 0 taken 9703 times.
✗ Branch 1 not taken.
9703 if(palpos>=0)
4909 {
4910 9703 hw_palette = &wavepal;
4911 9703 update_hw_pal = true;
4912 9703 }
4913 else
4914 {
4915 hw_palette = &RAMpal;
4916 update_hw_pal = true;
4917 }
4918
4919
2/2
✓ Branch 0 taken 1630104 times.
✓ Branch 1 taken 9703 times.
1639807 for(int32_t j=0; j+playing_field_offset<224; j++)
4920 {
4921
2/2
✓ Branch 0 taken 417306624 times.
✓ Branch 1 taken 1630104 times.
418936728 for(int32_t k=0; k<256; k++)
4922 {
4923 417306624 ofs=0;
4924
4925
4/4
✓ Branch 0 taken 211158272 times.
✓ Branch 1 taken 206148352 times.
✓ Branch 2 taken 106821120 times.
✓ Branch 3 taken 104337152 times.
417306624 if((j<(167-i))&&(j&1))
4926 {
4927 104337152 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4928 104337152 }
4929
4930 417306624 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4931 417306624 }
4932 1630104 }
4933
4934 9703 advanceframe(true);
4935 // animate_combos();
4936
4937
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9702 times.
9703 if(Quit)
4938 1 break;
4939 9702 }
4940
4941 232 destroy_bitmap(wavebuf);
4942 232 }
4943
4944 4326 void blackscr(int32_t fcnt,bool showsubscr)
4945 {
4946 4326 reset_pal_cycling();
4947 4326 script_drawing_commands.Clear();
4948
4949 4326 FFCore.warpScriptCheck();
4950 4326 bool showtime = game->should_show_time();
4951
2/2
✓ Branch 0 taken 4319 times.
✓ Branch 1 taken 129337 times.
133656 while(fcnt>0)
4952 {
4953 129337 clear_bitmap(framebuf);
4954
4955
2/2
✓ Branch 0 taken 59250 times.
✓ Branch 1 taken 70087 times.
129337 if(showsubscr)
4956 {
4957 70087 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4958
3/4
✓ Branch 0 taken 70087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✓ Branch 3 taken 68857 times.
70087 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4959 {
4960 1230 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4961 1230 }
4962 70087 }
4963
4964 129337 advanceframe(true);
4965
4966
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 129330 times.
129337 if(Quit)
4967 7 break;
4968
4969 129330 --fcnt;
4970 }
4971 4326 }
4972
4973 2666 void openscreen(int32_t shape)
4974 {
4975 2666 reset_pal_cycling();
4976 2666 black_opening_count=0;
4977
4978
3/4
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 2144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522 times.
2666 if(COOLSCROLL || shape>-1)
4979 {
4980 2144 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4981 2144 return;
4982 }
4983 else
4984 {
4985 522 Hero.setDontDraw(true);
4986 522 show_subscreen_dmap_dots=false;
4987 522 show_subscreen_numbers=false;
4988 522 show_subscreen_life=false;
4989 }
4990
4991 522 int32_t x=128;
4992
4993 522 FFCore.warpScriptCheck();
4994
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 41760 times.
42282 for(int32_t i=0; i<80; i++)
4995 {
4996 41760 draw_screen(tmpscr);
4997 //? draw_screen already draws the subscreen -DD
4998 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4999 41760 x=128-(((i*128/80)/8)*8);
5000
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(x>0)
5002 {
5003 41760 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5004 41760 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5005 41760 }
5006
5007 41760 advanceframe(true);
5008
5009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41760 times.
41760 if(Quit)
5010 {
5011 break;
5012 }
5013 41760 }
5014
5015 522 Hero.setDontDraw(false);
5016 522 show_subscreen_items=true;
5017 522 show_subscreen_dmap_dots=true;
5018 522 show_subscreen_numbers=true;
5019 522 show_subscreen_life=true;
5020 2666 }
5021
5022 4 void closescreen(int32_t shape)
5023 {
5024 4 reset_pal_cycling();
5025 4 black_opening_count=0;
5026
5027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(COOLSCROLL || shape>-1)
5028 {
5029 4 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5030 4 return;
5031 }
5032 else
5033 {
5034 Hero.setDontDraw(true);
5035 show_subscreen_dmap_dots=false;
5036 show_subscreen_numbers=false;
5037 // show_subscreen_items=false;
5038 show_subscreen_life=false;
5039 }
5040
5041 int32_t x=128;
5042
5043 FFCore.warpScriptCheck();
5044 for(int32_t i=79; i>=0; --i)
5045 {
5046 draw_screen(tmpscr);
5047 //? draw_screen already draws the subscreen -DD
5048 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5049 x=128-(((i*128/80)/8)*8);
5050
5051 if(x>0)
5052 {
5053 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5054 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5055 }
5056
5057 advanceframe(true);
5058
5059 if(Quit)
5060 {
5061 break;
5062 }
5063 }
5064
5065 Hero.setDontDraw(false);
5066 show_subscreen_items=true;
5067 show_subscreen_dmap_dots=true;
5068 4 }
5069
5070 296 int32_t TriforceCount()
5071 {
5072 296 int32_t c=0;
5073
5074
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 296 times.
2664 for(int32_t i=1; i<=8; i++)
5075
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1884 times.
4252 if(game->lvlitems[i]&liTRIFORCE)
5076 1884 ++c;
5077
5078 296 return c;
5079 }
5080
5081 int32_t onCustomGame()
5082 {
5083 int32_t file = getsaveslot();
5084
5085 if(file < 0)
5086 return D_O_K;
5087
5088 bool ret = (custom_game(file)!=0);
5089 return ret ? D_CLOSE : D_O_K;
5090 }
5091
5092 int32_t onContinue()
5093 {
5094 return D_CLOSE;
5095 }
5096
5097 int32_t onEsc() // Unused?? -L
5098 {
5099 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5100 }
5101
5102 int32_t onThrottleFPS()
5103 {
5104 Throttlefps = !Throttlefps;
5105 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5106 return D_O_K;
5107 }
5108
5109 int32_t onWinPosSave()
5110 {
5111 SaveWinPos = !SaveWinPos;
5112 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5113 return D_O_K;
5114 }
5115 int32_t onIntegerScaling()
5116 {
5117 scaleForceInteger = !scaleForceInteger;
5118 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5119 return D_O_K;
5120 }
5121 int32_t onStretchGame()
5122 {
5123 stretchGame = !stretchGame;
5124 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5125 return D_O_K;
5126 }
5127
5128 int32_t onClickToFreeze()
5129 {
5130 ClickToFreeze = !ClickToFreeze;
5131 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5132 return D_O_K;
5133 }
5134
5135 int32_t OnSaveZCConfig()
5136 {
5137 if(jwin_alert3(
5138 "Save Configuration",
5139 "Are you sure that you wish to save your present configuration settings?",
5140 "This will overwrite your prior settings!",
5141 NULL,
5142 "&Yes",
5143 "&No",
5144 NULL,
5145 'y',
5146 'n',
5147 0,
5148 get_zc_font(font_lfont)) == 1)
5149 {
5150 save_game_configs();
5151 return D_O_K;
5152 }
5153 else return D_O_K;
5154 }
5155
5156 int32_t OnnClearQuestDir()
5157 {
5158 auto current_path = fs::current_path() / "quests";
5159 if(jwin_alert3(
5160 "Clear Current Directory Cache",
5161 "Are you sure that you wish to reset where ZC Player looks for quests?",
5162 fmt::format("The new directory will be: {}", current_path.string()).c_str(),
5163 NULL,
5164 "&Yes",
5165 "&No",
5166 NULL,
5167 'y',
5168 'n',
5169 0,
5170 get_zc_font(font_lfont)) == 1)
5171 {
5172 zc_set_config("zeldadx","quest_dir","quests");
5173 flush_config_file();
5174 strcpy(qstdir,"quests");
5175 #ifdef __EMSCRIPTEN__
5176 em_sync_fs();
5177 #endif
5178 return D_O_K;
5179 }
5180 else return D_O_K;
5181 }
5182
5183 int32_t onConsoleZScript()
5184 {
5185 if ( !zscript_debugger )
5186 {
5187 AlertDialog("ZScript Debugger",
5188 "Enabling this will open the ZScript Debugger Console"
5189 "\nThis will display any messages logged by scripts,"
5190 " including script errors."
5191 "\nAre you sure that you wish to open the ZScript Debugger?",
5192 [&](bool ret,bool)
5193 {
5194 if(ret)
5195 {
5196 FFCore.ZScriptConsole(true);
5197 }
5198 }).show();
5199 return D_O_K;
5200 }
5201 else
5202 {
5203 FFCore.ZScriptConsole(false);
5204 return D_O_K;
5205 }
5206 }
5207
5208 int32_t onClrConsoleOnReload()
5209 {
5210 clearConsoleOnReload = !clearConsoleOnReload;
5211 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5212 return D_O_K;
5213 }
5214 int32_t onClrConsoleOnLoad()
5215 {
5216 clearConsoleOnLoad = !clearConsoleOnLoad;
5217 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5218 return D_O_K;
5219 }
5220
5221
5222 int32_t onFrameSkip()
5223 {
5224 FrameSkip = !FrameSkip;
5225 return D_O_K;
5226 }
5227
5228 int32_t onSaveDragResize()
5229 {
5230 SaveDragResize = !SaveDragResize;
5231 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5232 return D_O_K;
5233 }
5234
5235 int32_t onDragAspect()
5236 {
5237 DragAspect = !DragAspect;
5238 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5239 return D_O_K;
5240 }
5241
5242 int32_t onTransLayers()
5243 {
5244 TransLayers = !TransLayers;
5245 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5246 return D_O_K;
5247 }
5248
5249 int32_t onNESquit()
5250 {
5251 NESquit = !NESquit;
5252 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5253 return D_O_K;
5254 }
5255
5256 int32_t onVolKeys()
5257 {
5258 volkeys = !volkeys;
5259 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5260 return D_O_K;
5261 }
5262
5263 int32_t onShowFPS()
5264 {
5265 ShowFPS = !ShowFPS;
5266 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5267 return D_O_K;
5268 }
5269
5270 int32_t onShowTime()
5271 {
5272 ShowGameTime = !ShowGameTime;
5273 zc_set_config(cfg_sect,"showtime",ShowGameTime);
5274 return D_O_K;
5275 }
5276
5277 2161549134 bool is_Fkey(int32_t k)
5278 {
5279
2/2
✓ Branch 0 taken 219818556 times.
✓ Branch 1 taken 1941730578 times.
2161549134 switch(k)
5280 {
5281 case KEY_F1:
5282 case KEY_F2:
5283 case KEY_F3:
5284 case KEY_F4:
5285 case KEY_F5:
5286 case KEY_F6:
5287 case KEY_F7:
5288 case KEY_F8:
5289 case KEY_F9:
5290 case KEY_F10:
5291 case KEY_F11:
5292 case KEY_F12:
5293 219818556 return true;
5294 }
5295
5296 1941730578 return false;
5297 2161549134 }
5298
5299 void kb_getkey(DIALOG *d);
5300
5301 //Used by all keyboard key settings dialogues.
5302 void kb_clearjoystick(DIALOG *d)
5303 {
5304 d->flags|=D_SELECTED;
5305
5306 jwin_button_proc(MSG_DRAW,d,0);
5307 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5308 // text_mode(vc(11));
5309 textout_centre_ex(screen, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5310 textout_centre_ex(screen, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5311
5312 update_hw_screen(true);
5313
5314 clear_keybuf();
5315 int32_t k = next_press_key();
5316 clear_keybuf();
5317
5318 //shnarf
5319 //47=f1
5320 //59=esc
5321 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5322 // *((int32_t*)d->dp3) = k;
5323 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5324
5325
5326 d->flags&=~D_SELECTED;
5327 }
5328
5329 //Clears key to 0.
5330 //Used by all keyboard key settings dialogues.
5331 void kb_clearkey(DIALOG *d);
5332
5333 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5334 {
5335 switch(msg)
5336 {
5337 case MSG_KEY:
5338 case MSG_CLICK:
5339
5340 kb_clearjoystick(d);
5341
5342 while(gui_mouse_b())
5343 {
5344 clear_keybuf();
5345 rest(1);
5346 }
5347
5348 return D_REDRAW;
5349 }
5350
5351 return jwin_button_proc(msg,d,c);
5352 }
5353
5354 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5355 //Only used in keyboard settings dialogues to clear keys.
5356 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5357
5358 int32_t j_getbtn(DIALOG *d)
5359 {
5360 d->flags|=D_SELECTED;
5361 jwin_button_proc(MSG_DRAW,d,0);
5362 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5363 // text_mode(vc(11));
5364 int32_t y = screen->h/2 - 12;
5365 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5366 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5367 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5368
5369 update_hw_screen(true);
5370
5371 int32_t b = next_joy_input(true);
5372 if (b == -2)
5373 return D_CLOSE;
5374
5375 if(b>=0)
5376 *((int32_t*)d->dp3) = b;
5377
5378 d->flags&=~D_SELECTED;
5379
5380 return D_O_K;
5381 }
5382
5383 void j_getstick(DIALOG *d)
5384 {
5385 d->flags|=D_SELECTED;
5386 jwin_button_proc(MSG_DRAW,d,0);
5387 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5388 // text_mode(vc(11));
5389 int32_t y = screen->h/2 - 12;
5390 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5391 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5392 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5393
5394 update_hw_screen(true);
5395
5396 int32_t b = next_joy_input(false);
5397
5398 if(b>=0)
5399 *((int32_t*)d->dp3) = b;
5400
5401 d->flags&=~D_SELECTED;
5402 }
5403
5404 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5405 {
5406 switch(msg)
5407 {
5408 case MSG_KEY:
5409 case MSG_CLICK:
5410
5411 int ret = j_getbtn(d);
5412 if (ret != D_O_K)
5413 return ret;
5414
5415 while(gui_mouse_b()) {
5416 rest(1);
5417 clear_keybuf();
5418 }
5419
5420 return D_REDRAW;
5421 }
5422
5423 return jwin_button_proc(msg,d,c);
5424 }
5425
5426 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5427 {
5428 switch(msg)
5429 {
5430 case MSG_KEY:
5431 case MSG_CLICK:
5432
5433 j_getstick(d);
5434
5435 while(gui_mouse_b()) {
5436 rest(1);
5437 clear_keybuf();
5438 }
5439
5440 return D_REDRAW;
5441 }
5442
5443 return jwin_button_proc(msg,d,c);
5444 }
5445
5446 //shnarf
5447 extern const char *key_str[];
5448 std::string get_keystr(int key);
5449
5450 const char *pan_str[4] = { " MONO", " 1/2", " 3/4", " FULL" };
5451
5452 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5453 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5454 str_primary_stick[80], str_secondary_stick[80];
5455
5456 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5457 {
5458 //these are here to bypass compiler warnings about unused arguments
5459 c=c;
5460
5461 if (d->w == 1)
5462 {
5463 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5464 {
5465 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5466 return D_CLOSE;
5467 }
5468 }
5469
5470 if(msg==MSG_DRAW)
5471 {
5472 switch(d->w)
5473 {
5474 case 0:
5475 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5476 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5477 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5478 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5479 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5480 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5481 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5482 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5483 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5484 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5485 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5486 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5487 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5488 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5489 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5490 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5491 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5492 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5493 break;
5494
5495 case 1:
5496 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5497 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5498 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5499 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5500 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5501 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5502 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5503 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5504 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5505 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5506 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5507 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5508 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5509 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5510 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5511 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5512 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5513 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5514 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5515 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5516 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5517 break;
5518
5519 case 2:
5520 sprintf(str_a," %3d",midi_volume);
5521 sprintf(str_l," %3d",emusic_volume);
5522 sprintf(str_r," %3d",sfx_volume);
5523 strcpy(str_s,pan_str[pan_style]);
5524 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5525 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5526 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5527 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5528 break;
5529 }
5530 }
5531
5532 return D_O_K;
5533 }
5534
5535 int32_t set_vol(void *dp3, int32_t d2)
5536 {
5537 switch(((int32_t*)dp3)[0])
5538 {
5539 case 0:
5540 midi_volume = zc_min(d2<<3,255);
5541 break;
5542
5543 case 1:
5544 digi_volume = zc_min(d2<<3,255);
5545 break;
5546
5547 case 2:
5548 emusic_volume = zc_min(d2<<3,255);
5549 break;
5550
5551 case 3:
5552 sfx_volume = zc_min(d2<<3,255);
5553 break;
5554 }
5555
5556 // text_mode(vc(11));
5557 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]," %3d",zc_min(d2<<3,255));
5558 return D_O_K;
5559 }
5560
5561 int32_t set_pan(void *dp3, int32_t d2)
5562 {
5563 pan_style = vbound(d2,0,3);
5564 // text_mode(vc(11));
5565 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5566 return D_O_K;
5567 }
5568
5569 static int32_t gamepad_joys_list[] =
5570 {
5571 61,
5572 -1
5573 };
5574
5575 static int32_t gamepad_btn_list[] =
5576 {
5577 6,
5578 7,8,9,10,11,12,13,14,15,16,17,
5579 18,19,20,21,22,23,24,25,26,27,28,
5580 29,30,31,32,33,34,35,36,37,38,39,
5581 -1
5582 };
5583
5584 static int32_t gamepad_dirs_list[] =
5585 {
5586 40,41,42,43,
5587 44,45,46,47,
5588 48,49,50,51,
5589 52,53,54,55,
5590 56,57,58,59,
5591 60,
5592 -1
5593 };
5594
5595 static TABPANEL gamepad_tabs[] =
5596 {
5597 // (text)
5598 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5599 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5600 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5601 { NULL, 0, NULL, 0, NULL }
5602 };
5603
5604 const char *joy_list(int32_t index, int32_t *list_size)
5605 {
5606 if (index == -1)
5607 {
5608 *list_size = al_get_num_joysticks();
5609 return NULL;
5610 }
5611
5612 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5613 if (!joy)
5614 {
5615 return "?";
5616 }
5617
5618 return al_get_joystick_name(joy);
5619 }
5620
5621 350 static ListData joy__list(joy_list, &font);
5622
5623 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5624 {
5625 int32_t d2 = d->d2;
5626 int32_t ret = jwin_droplist_proc(msg,d,c);
5627
5628 if(d2!=d->d2)
5629 {
5630 joystick_index = d->d2;
5631 ret |= D_REDRAW_ALL;
5632 }
5633
5634 return ret;
5635 }
5636
5637 static DIALOG gamepad_dlg[] =
5638 {
5639 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5640 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5641 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5642 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5643 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5644 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5645 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5646 // 6
5647 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5648 // 7
5649 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5650 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5651 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5652 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5653 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5654 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5655 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5656 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5657 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5658 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5659 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5660 // 18
5661 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5662 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5663 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5664 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5665 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5666 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5667 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5668 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5669 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5670 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5671 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5672 // 29
5673 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5674 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5675 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5676 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5677 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5678 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5679 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5680 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5681 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5682 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5683 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5684 // 40
5685 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5686 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5687 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5688 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5689 // 44
5690 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5691 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5692 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5693 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5694 // 48
5695 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5696 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5697 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5698 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5699 // 52
5700 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5701 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5702 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5703 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5704 // 56
5705 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5706 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5707 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5708 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5709 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5710
5711 // 61
5712 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5713
5714 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5715 };
5716
5717 static int32_t keyboard_keys_list[] =
5718 {
5719 6,7,8,9,10,
5720 11,12,13,14,15,16,17,18,19,20,
5721 21,22,23,24,25,26,27,28,29,30,
5722 31,32,33,34,35,36,37,38,39,40,
5723 -1
5724 };
5725
5726 static int32_t keyboard_dirs_list[] =
5727 {
5728 41,42,43,44,
5729 45,46,47,48,
5730 49,50,51,52,
5731 53,54,55,56,
5732 -1
5733 };
5734
5735 static int32_t keyboard_mods_list[] =
5736 {
5737 57,58,59,60,
5738 61,62,63,64,
5739 65,66,67,68,
5740 69,70,71,72,
5741 -1
5742 };
5743
5744 static TABPANEL keyboard_control_tabs[] =
5745 {
5746 // (text)
5747 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5748 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5749 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5750 { NULL, 0, NULL, 0, NULL }
5751 };
5752
5753 static DIALOG keyboard_control_dlg[] =
5754 {
5755 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5756 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5757 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5758 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5759 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5760 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5761 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5762 // Keys
5763 // 6
5764 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5765 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5766 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5767 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5768 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5769 // 11
5770 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5771 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5772 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5773 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5774 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5775 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5776 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5777 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5778 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5779 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5780 // 21
5781 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5782 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5783 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5784 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5785 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5786 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5787 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5788 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5789 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5790 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5791 // 31
5792 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5793 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5794 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5795 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5796 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5797 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5798 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5799 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5800 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5801 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5802 // Dirs
5803 // 41
5804 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5805 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5806 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5807 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5808 // 45
5809 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5810 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5811 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5812 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5813 // 49
5814 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5815 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5816 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5817 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5818 // 53
5819 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5820 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5821 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5822 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5823 // Mods
5824 // 57
5825 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5826 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5827 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5828 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5829 // 61
5830 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5831 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5832 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5833 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5834 // 65
5835 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5836 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5837 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5838 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5839 // 69
5840 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5841 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5842 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5843 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5844 // 73
5845 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5846 };
5847
5848 int32_t midi_dp[3] = {0,0,0};
5849 int32_t emus_dp[3] = {2,0,0};
5850 int32_t sfx_dp[3] = {3,0,0};
5851 int32_t pan_dp[3] = {0,0,0};
5852
5853 static DIALOG sound_dlg[] =
5854 {
5855 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5856 350 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5857 350 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5858 350 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5859 350 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5860 350 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 350 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5862 350 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5863 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5864 350 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5865 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5866 // 10
5867 350 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5868 350 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5869 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5870 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5872 350 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5873 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5874 350 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5875 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5876 350 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5877 //20
5878 350 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5879 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5880 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 350 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "MIDI Volume", NULL, NULL },
5883 350 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Music Volume (Enhanced Music)", NULL, NULL },
5884 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5885 350 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5886 350 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5887 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5888 //30
5889 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5890 350 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5891 350 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5892 };
5893
5894 char zc_builddate[80];
5895 char zc_aboutstr[80];
5896
5897 static DIALOG about_dlg[] =
5898 {
5899 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5900 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5901 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5902 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5903 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5904 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5905 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5906 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5907 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5908 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5909 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5910 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5911 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5912 };
5913
5914
5915 static DIALOG quest_dlg[] =
5916 {
5917 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5918 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5919 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5920 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5921 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5922 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5923 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5924 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5925 { jwin_text_proc, 130, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5926 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5927 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5928 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5929 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5930 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5931 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5933 };
5934
5935 static DIALOG triforce_dlg[] =
5936 {
5937 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5938 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5939 // 1
5940 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5941 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5942 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5943 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5944 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5945 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5946 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5947 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5948 // 9
5949 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5950 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5951 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5952 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5953 };
5954
5955 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5956 {
5957 go();
5958 int32_t ret=0;
5959 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5960 comeback();
5961 return ret != 0;
5962 }
5963
5964
5965 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5966 {
5967 if(def!=modulepath)
5968 strcpy(modulepath,def);
5969
5970 if(!usefilename)
5971 {
5972 int32_t i=(int32_t)strlen(modulepath);
5973
5974 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5975 modulepath[i--]=0;
5976 }
5977
5978 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5979 int32_t ret=0;
5980 int32_t sel=0;
5981
5982 if(list==NULL)
5983 {
5984 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5985 }
5986 else
5987 {
5988 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5989 }
5990
5991 return ret!=0;
5992 }
5993
5994 int32_t onToggleRecordingNewSaves()
5995 {
5996 if (zc_get_config("zeldadx", "replay_new_saves", false))
5997 {
5998 zc_set_config("zeldadx", "replay_new_saves", false);
5999 }
6000 else
6001 {
6002 zc_set_config("zeldadx", "replay_new_saves", true);
6003 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6004 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6005 }
6006 return D_O_K;
6007 }
6008
6009 int32_t onToggleSnapshotAllFrames()
6010 {
6011 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6012 return D_O_K;
6013 }
6014
6015 int32_t onStopReplayOrRecord()
6016 {
6017 if (replay_is_replaying())
6018 {
6019 replay_quit();
6020 }
6021 else if (replay_get_mode() == ReplayMode::Record)
6022 {
6023 if (!replay_get_meta_bool("test_mode"))
6024 {
6025 jwin_alert("Recording", "You cannot stop recording a save file.",
6026 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6027 return D_CLOSE;
6028 }
6029
6030 if (jwin_alert("Stop Recording",
6031 "Save replay to disk and stop recording?",
6032 "This will stop the recording.",
6033 NULL,
6034 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6035 return D_CLOSE;
6036
6037 replay_save();
6038 replay_stop();
6039 }
6040 return D_O_K;
6041 }
6042
6043 static int32_t handle_on_load_replay(ReplayMode mode)
6044 {
6045 bool ctrl = CHECK_CTRL_CMD;
6046 if (Playing)
6047 {
6048 if (jwin_alert("Replay - Warning!",
6049 "Loading a replay will exit the current game.",
6050 "All unsaved progress will be lost.",
6051 "Do you wish to continue?",
6052 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6053 return D_CLOSE;
6054 }
6055
6056 std::string mode_string = replay_mode_to_string(mode);
6057 mode_string[0] = std::toupper(mode_string[0]);
6058
6059 std::string line_1 = "Select a replay file to play back.";
6060 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6061 std::string line_3 = "You can stop the replay and take over manually any time.";
6062 if (mode == ReplayMode::Update)
6063 {
6064 line_1 = "Select a replay file to update.";
6065 line_2 = "WARNING: be sure to back up the zplay file";
6066 line_3 = "and verify that the updated replay works as expected!";
6067 }
6068
6069 if (jwin_alert(mode_string.c_str(),
6070 line_1.c_str(),
6071 line_2.c_str(),
6072 line_3.c_str(),
6073 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6074 {
6075 char replay_path[2048];
6076 strcpy(replay_path, "replays/");
6077 if(ctrl && devpwd())
6078 strcpy(replay_path, "../../tests/replays");
6079 if (jwin_file_select_ex(
6080 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6081 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6082 return D_CLOSE;
6083
6084 replay_quit();
6085 load_replay_file_deferred(mode, replay_path);
6086 Quit = qRESET;
6087 return D_CLOSE;
6088 }
6089 return D_O_K;
6090 }
6091
6092 int32_t onLoadReplay()
6093 {
6094 return handle_on_load_replay(ReplayMode::Replay);
6095 }
6096
6097 int32_t onLoadReplayAssert()
6098 {
6099 return handle_on_load_replay(ReplayMode::Assert);
6100 }
6101
6102 int32_t onLoadReplayUpdate()
6103 {
6104 return handle_on_load_replay(ReplayMode::Update);
6105 }
6106
6107 int32_t onSaveReplay()
6108 {
6109 if (replay_get_mode() == ReplayMode::Record)
6110 {
6111 if (!replay_get_meta_bool("test_mode"))
6112 {
6113 if (jwin_alert("Save Replay",
6114 "This will save a copy of the replay up to this point.",
6115 "The official replay file will be untouched.",
6116 "Do you wish to continue?",
6117 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6118 return D_CLOSE;
6119
6120 char replay_path[2048];
6121 strcpy(replay_path, replay_get_replay_path().string().c_str());
6122 if (jwin_file_select_ex(
6123 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6124 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6125 return D_CLOSE;
6126
6127 if (fileexists(replay_path))
6128 {
6129 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6130 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6131 return D_CLOSE;
6132 }
6133
6134 replay_save(replay_path);
6135 }
6136 else
6137 {
6138 replay_save();
6139 }
6140 }
6141 return D_O_K;
6142 }
6143
6144 enum
6145 {
6146 MENUID_REPLAY_RECORDNEW,
6147 MENUID_REPLAY_STOP,
6148 MENUID_REPLAY_SAVE,
6149 MENUID_REPLAY_SNAP_ALL,
6150 };
6151
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu replay_menu
6152 2800 {
6153
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Record new saves", onToggleRecordingNewSaves, MENUID_REPLAY_RECORDNEW },
6154
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Stop replay", onStopReplayOrRecord, MENUID_REPLAY_STOP },
6155
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Load replay", onLoadReplay },
6156
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Load replay (assert)", onLoadReplayAssert },
6157
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Load replay (update)", onLoadReplayUpdate },
6158
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Save replay", onSaveReplay, MENUID_REPLAY_SAVE },
6159
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Snapshot all frames", onToggleSnapshotAllFrames, MENUID_REPLAY_SNAP_ALL },
6160 };
6161
6162 static DIALOG credits_dlg[] =
6163 {
6164 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6165 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6166 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6167 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6168 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6169 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6170 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6171 };
6172
6173 350 static ListData dmap_list(dmaplist, &font);
6174
6175 static DIALOG goto_dlg[] =
6176 {
6177 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6178 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6179 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6180 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6181 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6182 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6183 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6184 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6185 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6186 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6187 };
6188
6189 int32_t onGoTo()
6190 {
6191 bool music = false;
6192 music = music;
6193 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6194
6195 goto_dlg[0].dp2=get_zc_font(font_lfont);
6196 goto_dlg[4].d2=cheat_goto_dmap;
6197 goto_dlg[6].dp=cheat_goto_screen_str;
6198
6199 clear_keybuf();
6200
6201 large_dialog(goto_dlg);
6202
6203 if(do_zqdialog(goto_dlg,4)==1)
6204 {
6205 // dmap, screen
6206 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6207 };
6208
6209 return D_O_K;
6210 }
6211
6212 int32_t onGoToComplete()
6213 {
6214 if(!Playing)
6215 {
6216 return D_O_K;
6217 }
6218
6219 enter_sys_pal();
6220 music_pause();
6221 pause_all_sfx();
6222 onGoTo();
6223 eat_buttons();
6224
6225 zc_readrawkey(KEY_ESC);
6226
6227 exit_sys_pal();
6228 music_resume();
6229 resume_all_sfx();
6230 return D_O_K;
6231 }
6232
6233 int32_t onCredits()
6234 {
6235 return D_O_K;
6236 }
6237
6238 const char *midilist(int32_t index, int32_t *list_size)
6239 {
6240 if(index<0)
6241 {
6242 *list_size=0;
6243
6244 for(int32_t i=0; i<MAXMIDIS; i++)
6245 if(tunes[i].data)
6246 ++(*list_size);
6247
6248 return NULL;
6249 }
6250
6251 int32_t i=0,m=0;
6252
6253 while(m<=index && i<=MAXMIDIS)
6254 {
6255 if(tunes[i].data)
6256 ++m;
6257
6258 ++i;
6259 }
6260
6261 --i;
6262
6263 if(i==MAXMIDIS && m<index)
6264 return "(null)";
6265
6266 return tunes[i].title;
6267 }
6268
6269 /* ------- MIDI info stuff -------- */
6270
6271 char *text;
6272 midi_info *zmi;
6273 bool dialog_running;
6274 bool listening;
6275
6276 void get_info(int32_t index);
6277
6278 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6279 {
6280 int32_t d2 = d->d2;
6281 int32_t ret = jwin_droplist_proc(msg,d,c);
6282
6283 if(d2!=d->d2)
6284 {
6285 get_info(d->d2);
6286 }
6287
6288 return ret;
6289 }
6290
6291 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6292 {
6293 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6294
6295 int32_t ret = jwin_button_proc(msg,d,c);
6296
6297 if(ret == D_CLOSE)
6298 {
6299 // get current midi index
6300 int32_t index = (d+(d->d1))->d2;
6301 int32_t i=0, m=0;
6302
6303 while(m<=index && i<=MAXMIDIS)
6304 {
6305 if(tunes[i].data)
6306 ++m;
6307
6308 ++i;
6309 }
6310
6311 --i;
6312 jukebox(i);
6313 listening = true;
6314 ret = D_O_K;
6315 }
6316
6317 return ret;
6318 }
6319
6320 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6321 {
6322 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6323
6324 int32_t ret = jwin_button_proc(msg,d,c);
6325
6326 if(ret == D_CLOSE)
6327 {
6328 // get current midi index
6329 int32_t index = (d+(d->d1))->d2;
6330 int32_t i=0, m=0;
6331
6332 while(m<=index && i<=MAXMIDIS)
6333 {
6334 if(tunes[i].data)
6335 ++m;
6336
6337 ++i;
6338 }
6339
6340 --i;
6341
6342 // get file name
6343
6344 int32_t sel=0;
6345 //struct ffblk f;
6346 char title[40] = "Save MIDI: ";
6347 char fname[2048];
6348 memset(fname,0,2048);
6349 static EXT_LIST list[] =
6350 {
6351 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6352 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6353 { NULL, NULL }
6354 };
6355
6356 strcpy(title+11, tunes[i].title);
6357 title[39] = '\0';
6358
6359 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6360 goto done;
6361
6362 if(exists(fname))
6363 {
6364 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6365 goto done;
6366 }
6367
6368 // save midi i
6369
6370 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6371 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6372
6373 done:
6374 chop_path(fname);
6375 ret = D_REDRAW;
6376 }
6377
6378 return ret;
6379 }
6380
6381 350 static ListData midi_list(midilist, &font);
6382
6383 static DIALOG midi_dlg[] =
6384 {
6385 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6386 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6387 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6388 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6389 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6390 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6391 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6392 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6393 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6394 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6395 };
6396
6397 void get_info(int32_t index)
6398 {
6399 int32_t i=0, m=0;
6400
6401 while(m<=index && i<=MAXMIDIS)
6402 {
6403 if(tunes[i].data)
6404 ++m;
6405
6406 ++i;
6407 }
6408
6409 --i;
6410
6411 if(i==MAXMIDIS && m<index)
6412 strcpy(text,"(null)");
6413 else
6414 {
6415 get_midi_info((MIDI*)tunes[i].data,zmi);
6416 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6417 }
6418
6419 midi_dlg[0].dp2=get_zc_font(font_lfont);
6420 midi_dlg[3].dp = text;
6421 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6422 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6423
6424 if(dialog_running)
6425 {
6426 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6427 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6428 }
6429 }
6430
6431 int32_t onMIDICredits()
6432 {
6433 text = (char*)malloc(4096);
6434 zmi = (midi_info*)malloc(sizeof(midi_info));
6435
6436 if(!text || !zmi)
6437 {
6438 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6439 return D_O_K;
6440 }
6441
6442 bool do_pause_midi = midi_pos >= 0 && currmidi;
6443 auto restore_midi = currmidi;
6444 if(do_pause_midi)
6445 {
6446 paused_midi_pos = midi_pos;
6447 stop_midi();
6448 midi_suspended = midissuspHALTED;
6449 }
6450
6451 midi_dlg[0].dp2=get_zc_font(font_lfont);
6452 midi_dlg[2].d1 = 0;
6453 midi_dlg[2].d2 = 0;
6454 midi_dlg[4].flags = D_EXIT;
6455 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6456
6457 listening = false;
6458 dialog_running=false;
6459 get_info(0);
6460
6461 dialog_running=true;
6462
6463 large_dialog(midi_dlg);
6464
6465 do_zqdialog(midi_dlg,0);
6466 dialog_running=false;
6467
6468 if(listening)
6469 music_stop();
6470
6471 if(do_pause_midi)
6472 {
6473 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6474 midi_suspended = midissuspRESUME;
6475 currmidi = restore_midi;
6476 midi_pos = paused_midi_pos;
6477 }
6478
6479 if(text) free(text);
6480 if(zmi) free(zmi);
6481 return D_O_K;
6482 }
6483
6484 int32_t onAbout()
6485 {
6486 char buf1[80]={0};
6487 std::ostringstream oss;
6488 sprintf(buf1,ZC_PLAYER_NAME);
6489 oss << buf1 << '\n';
6490 sprintf(buf1,"Version: %s", getVersionString());
6491 oss << buf1 << '\n';
6492 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6493 oss << buf1 << '\n';
6494 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6495 oss << buf1 << '\n';
6496
6497 InfoDialog("About ZC", oss.str()).show();
6498 return D_O_K;
6499 }
6500
6501 int32_t onQuest()
6502 {
6503 char fname[100];
6504 strcpy(fname, get_filename(qstpath));
6505 quest_dlg[0].dp2=get_zc_font(font_lfont);
6506 quest_dlg[1].dp = fname;
6507
6508 if(QHeader.quest_number==0)
6509 sprintf(str_a,"Custom");
6510 else
6511 sprintf(str_a,"%d",QHeader.quest_number);
6512
6513 sprintf(str_s,"%s",QHeader.getVerStr());
6514
6515 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6516 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6517
6518 large_dialog(quest_dlg);
6519
6520 do_zqdialog(quest_dlg, 0);
6521 return D_O_K;
6522 }
6523
6524 void call_vidmode_dlg();
6525 int32_t onVidMode()
6526 {
6527 call_vidmode_dlg();
6528 return D_O_K;
6529 }
6530
6531 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6532 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6533 //Added an extra statement, so that if the key is cleared to 0, the cleared
6534 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6535
6536 void load_ukeys(int32_t* arr)
6537 {
6538 arr[ukey_a] = Akey;
6539 arr[ukey_b] = Bkey;
6540 arr[ukey_s] = Skey;
6541 arr[ukey_l] = Lkey;
6542 arr[ukey_r] = Rkey;
6543 arr[ukey_p] = Pkey;
6544 arr[ukey_ex1] = Exkey1;
6545 arr[ukey_ex2] = Exkey2;
6546 arr[ukey_ex3] = Exkey3;
6547 arr[ukey_ex4] = Exkey4;
6548 arr[ukey_du] = DUkey;
6549 arr[ukey_dd] = DDkey;
6550 arr[ukey_dl] = DLkey;
6551 arr[ukey_dr] = DRkey;
6552 arr[ukey_mod1a] = cheat_modifier_keys[0];
6553 arr[ukey_mod1b] = cheat_modifier_keys[1];
6554 arr[ukey_mod2a] = cheat_modifier_keys[2];
6555 arr[ukey_mod2b] = cheat_modifier_keys[3];
6556 };
6557
6558 static const char* ukey_names[] = {
6559 "A", "B", "Start", "L", "R", "Map",
6560 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6561 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6562 "Cheat Mod R1", "Cheat Mod R2",
6563 };
6564 std::string get_ukey_name(int32_t k)
6565 {
6566 if (k < num_ukey) return ukey_names[k];
6567 return "";
6568 }
6569
6570 int32_t onKeyboard()
6571 {
6572 int32_t a = Akey;
6573 int32_t b = Bkey;
6574 int32_t s = Skey;
6575 int32_t l = Lkey;
6576 int32_t r = Rkey;
6577 int32_t p = Pkey;
6578 int32_t ex1 = Exkey1;
6579 int32_t ex2 = Exkey2;
6580 int32_t ex3 = Exkey3;
6581 int32_t ex4 = Exkey4;
6582 int32_t du = DUkey;
6583 int32_t dd = DDkey;
6584 int32_t dl = DLkey;
6585 int32_t dr = DRkey;
6586 int32_t mod1a = cheat_modifier_keys[0];
6587 int32_t mod1b = cheat_modifier_keys[1];
6588 int32_t mod2a = cheat_modifier_keys[2];
6589 int32_t mod2b = cheat_modifier_keys[3];
6590 bool done=false;
6591 int32_t ret;
6592
6593 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6594
6595 large_dialog(keyboard_control_dlg);
6596
6597 while(!done)
6598 {
6599 ret = do_zqdialog(keyboard_control_dlg,3);
6600
6601 if(ret==3) // OK
6602 {
6603 int32_t ukeys[num_ukey];
6604 load_ukeys(ukeys);
6605 std::vector<std::string> uniqueError;
6606 for(int32_t q = 0; q < num_ukey; ++q)
6607 {
6608 for(int32_t p = q+1; p < num_ukey; ++p)
6609 {
6610 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6611 {
6612 char buf[64];
6613 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6614 std::string str(buf);
6615 uniqueError.push_back(str);
6616 }
6617 }
6618 }
6619 if(uniqueError.size() == 0)
6620 {
6621 done = true;
6622 save_control_configs(true);
6623 }
6624 else
6625 {
6626 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6627 box_out("Cannot have duplicate keybinds!"); box_eol();
6628 for(std::vector<std::string>::iterator it = uniqueError.begin();
6629 it != uniqueError.end(); ++it)
6630 {
6631 box_out((*it).c_str()); box_eol();
6632 }
6633 box_end(true);
6634 }
6635 }
6636 else // Cancel
6637 {
6638 Akey = a;
6639 Bkey = b;
6640 Skey = s;
6641 Lkey = l;
6642 Rkey = r;
6643 Pkey = p;
6644 Exkey1 = ex1;
6645 Exkey2 = ex2;
6646 Exkey3 = ex3;
6647 Exkey4 = ex4;
6648 DUkey = du;
6649 DDkey = dd;
6650 DLkey = dl;
6651 DRkey = dr;
6652 cheat_modifier_keys[0] = mod1a;
6653 cheat_modifier_keys[1] = mod1b;
6654 cheat_modifier_keys[2] = mod2a;
6655 cheat_modifier_keys[3] = mod2b;
6656
6657 done=true;
6658 }
6659
6660 rest(1);
6661 }
6662
6663 return D_O_K;
6664 }
6665
6666 int32_t onGamepad()
6667 {
6668 if (al_get_num_joysticks() == 0)
6669 {
6670 InfoDialog("ZC", "No gamepads detected.").show();
6671 return D_O_K;
6672 }
6673
6674 int32_t a = Abtn;
6675 int32_t b = Bbtn;
6676 int32_t s = Sbtn;
6677 int32_t l = Lbtn;
6678 int32_t r = Rbtn;
6679 int32_t m = Mbtn;
6680 int32_t p = Pbtn;
6681 int32_t ex1 = Exbtn1;
6682 int32_t ex2 = Exbtn2;
6683 int32_t ex3 = Exbtn3;
6684 int32_t ex4 = Exbtn4;
6685 int32_t up = DUbtn;
6686 int32_t down = DDbtn;
6687 int32_t left = DLbtn;
6688 int32_t right = DRbtn;
6689 int32_t joy = joystick_index;
6690 int32_t stick_1 = js_stick_1_x_stick;
6691 int32_t stick_2 = js_stick_2_x_stick;
6692
6693 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6694 if(analog_movement)
6695 gamepad_dlg[56].flags|=D_SELECTED;
6696 else
6697 gamepad_dlg[56].flags&=~D_SELECTED;
6698
6699 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6700 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6701 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6702 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6703 // requires remapping every time.
6704 if (joystick_index >= al_get_num_joysticks())
6705 joystick_index = 0;
6706 gamepad_dlg[61].d2 = joystick_index;
6707
6708 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6709 if (!gamepad_dlg_cur_joystick)
6710 {
6711 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6712 return D_CLOSE;
6713 }
6714
6715 large_dialog(gamepad_dlg);
6716
6717 int32_t ret = do_zqdialog(gamepad_dlg,4);
6718
6719 if(ret == 4) //OK
6720 {
6721 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6722 joystick_index = gamepad_dlg[61].d2;
6723 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6724 if (!gamepad_dlg_cur_joystick)
6725 {
6726 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6727 return D_CLOSE;
6728 }
6729 js_stick_1_y_stick = js_stick_1_x_stick;
6730 js_stick_2_y_stick = js_stick_2_x_stick;
6731 save_control_configs(false);
6732 }
6733 else //Cancel
6734 {
6735 Abtn = a;
6736 Bbtn = b;
6737 Sbtn = s;
6738 Lbtn = l;
6739 Rbtn = r;
6740 Mbtn = m;
6741 Pbtn = p;
6742 Exbtn1 = ex1;
6743 Exbtn2 = ex2;
6744 Exbtn3 = ex3;
6745 Exbtn4 = ex4;
6746 DUbtn = up;
6747 DDbtn = down;
6748 DLbtn = left;
6749 DRbtn = right;
6750 joystick_index = joy;
6751 js_stick_1_x_stick = stick_1;
6752 js_stick_2_x_stick = stick_2;
6753 }
6754
6755 return D_O_K;
6756 }
6757
6758 int32_t onCheatKeys()
6759 {
6760 int32_t oldcheats[Cheat::Last][2];
6761 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6762
6763 bool done=false;
6764
6765 while(!done)
6766 {
6767 bool confirm = false;
6768 CheatKeysDialog(&confirm).show();
6769 if(confirm) // OK
6770 {
6771 std::vector<std::string> uniqueError;
6772 char buf[512];
6773 for(size_t q = 1; q < Cheat::Last; ++q)
6774 {
6775 if(cheatkeys[q][1] && !cheatkeys[q][0])
6776 {
6777 cheatkeys[q][0] = cheatkeys[q][1];
6778 cheatkeys[q][1] = 0;
6779 }
6780 }
6781 for(size_t q = 1; q < Cheat::Last; ++q)
6782 {
6783 if(!bindable_cheat((Cheat)q)) continue;
6784 for(size_t p = q+1; p < Cheat::Last; ++p)
6785 {
6786 if(!bindable_cheat((Cheat)p)) continue;
6787 for(size_t q2 = 0; q2 <= 1; ++q2)
6788 for(size_t p2 = 0; p2 <= 1; ++p2)
6789 {
6790 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6791 {
6792 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6793 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6794 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6795 get_keystr(cheatkeys[q][q2])));
6796 }
6797 }
6798 }
6799 }
6800 if(uniqueError.size() == 0)
6801 {
6802 done = true;
6803 save_cheatkeys();
6804 }
6805 else
6806 {
6807 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6808 box_out("Cannot have duplicate keybinds!"); box_eol();
6809 for(std::vector<std::string>::iterator it = uniqueError.begin();
6810 it != uniqueError.end(); ++it)
6811 {
6812 box_out((*it).c_str()); box_eol();
6813 }
6814 box_end(true);
6815 }
6816 }
6817 else // Cancel
6818 {
6819 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6820 done=true;
6821 }
6822 rest(1);
6823 }
6824
6825 return D_O_K;
6826 }
6827
6828 int32_t onSound()
6829 {
6830 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6831 {
6832 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6833 {
6834 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6835 }
6836 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6837 {
6838 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6839 }
6840 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6841 {
6842 emusic_volume = (int32_t)FFCore.usr_music_volume;
6843 }
6844 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6845 {
6846 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6847 }
6848 }
6849 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6850 {
6851 pan_style = (int32_t)FFCore.usr_panstyle;
6852 }
6853
6854 int32_t m = midi_volume;
6855 int32_t e = emusic_volume;
6856 int32_t s = sfx_volume;
6857 int32_t p = pan_style;
6858 pan_style = vbound(pan_style,0,3);
6859
6860 sound_dlg[0].dp2=get_zc_font(font_lfont);
6861
6862 large_dialog(sound_dlg);
6863
6864 midi_dp[1] = sound_dlg[6].x;
6865 midi_dp[2] = sound_dlg[6].y;
6866 emus_dp[1] = sound_dlg[8].x;
6867 emus_dp[2] = sound_dlg[8].y;
6868 sfx_dp[1] = sound_dlg[10].x;
6869 sfx_dp[2] = sound_dlg[10].y;
6870 pan_dp[1] = sound_dlg[11].x;
6871 pan_dp[2] = sound_dlg[11].y;
6872 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6873 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6874 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6875 sound_dlg[20].d2 = pan_style;
6876
6877 int32_t ret = do_zqdialog(sound_dlg,1);
6878
6879 if(ret==2)
6880 {
6881 master_volume(digi_volume,midi_volume);
6882 if (zcmusic)
6883 zcmusic_set_volume(zcmusic, emusic_volume);
6884
6885 int32_t temp_volume = sfx_volume;
6886 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6887 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6888 for(int32_t i=0; i<WAV_COUNT; ++i)
6889 {
6890 if(sfx_voice[i] >= 0)
6891 voice_set_volume(sfx_voice[i], temp_volume);
6892 }
6893 zc_set_config(sfx_sect,"midi",midi_volume);
6894 zc_set_config(sfx_sect,"sfx",sfx_volume);
6895 zc_set_config(sfx_sect,"emusic",emusic_volume);
6896 zc_set_config(sfx_sect,"pan",pan_style);
6897 }
6898 else
6899 {
6900 midi_volume = m;
6901 emusic_volume = e;
6902 sfx_volume = s;
6903 pan_style = p;
6904 }
6905
6906 return D_O_K;
6907 }
6908
6909 int32_t queding(char const* s1, char const* s2, char const* s3)
6910 {
6911 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6912 }
6913
6914 int32_t onQuit()
6915 {
6916 if(Playing)
6917 {
6918 int32_t ret=0;
6919
6920 if(get_qr(qr_NOCONTINUE))
6921 {
6922 if(standalone_mode)
6923 {
6924 ret=queding("End current game?",
6925 "The continue screen is disabled; the game",
6926 "will be reloaded from the last save.");
6927 }
6928 else
6929 {
6930 ret=queding("End current game?",
6931 "The continue screen is disabled. You will",
6932 "be returned to the file select screen.");
6933 }
6934 }
6935 else
6936 ret=queding("End current game?",NULL,NULL);
6937
6938 if(ret==1)
6939 {
6940 disableClickToFreeze=false;
6941 Quit=qQUIT;
6942
6943 // Trying to evade a door repair charge?
6944 if(repaircharge)
6945 {
6946 game->change_drupy(-repaircharge);
6947 repaircharge=0;
6948 }
6949
6950 return D_CLOSE;
6951 }
6952 }
6953
6954 return D_O_K;
6955 }
6956
6957 int32_t onTryQuitMenu()
6958 {
6959 return onTryQuit(true);
6960 }
6961
6962 int32_t onTryQuit(bool inMenu)
6963 {
6964 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6965 {
6966 if(active_cutscene.can_f6())
6967 {
6968 if(get_qr(qr_OLD_F6))
6969 {
6970 if(inMenu) onQuit();
6971 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
6972 }
6973 else
6974 {
6975 disableClickToFreeze=false;
6976 GameFlags |= GAMEFLAG_TRYQUIT;
6977 }
6978 return D_CLOSE;
6979 }
6980 else active_cutscene.error();
6981 }
6982
6983 return D_O_K;
6984 }
6985
6986 int32_t onReset()
6987 {
6988 if(queding(" Reset system? ",NULL,NULL)==1)
6989 {
6990 disableClickToFreeze=false;
6991 Quit=qRESET;
6992 replay_quit();
6993 return D_CLOSE;
6994 }
6995
6996 return D_O_K;
6997 }
6998
6999 int32_t onExit()
7000 {
7001 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7002 {
7003 Quit=qEXIT;
7004 return D_CLOSE;
7005 }
7006
7007 return D_O_K;
7008 }
7009
7010 int32_t onDebug()
7011 {
7012 if(debug_enabled)
7013 set_debug(!get_debug());
7014 return D_O_K;
7015 }
7016
7017 int32_t onHeartBeep()
7018 {
7019 heart_beep=!heart_beep;
7020 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7021 return D_O_K;
7022 }
7023
7024 int32_t onSaveIndicator()
7025 {
7026 use_save_indicator = use_save_indicator ? 0 : 1;
7027 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7028 return D_O_K;
7029 }
7030
7031 int32_t onEpilepsy()
7032 {
7033 if(jwin_alert3(
7034 "Epilepsy Flash Reduction",
7035 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7036 "Disabling this will restore standard flash and wavy behaviour.",
7037 "Proceed?",
7038 "&Yes",
7039 "&No",
7040 NULL,
7041 'y',
7042 'n',
7043 0,
7044 get_zc_font(font_lfont)) == 1)
7045 {
7046 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7047 zc_set_config("zeldadx","checked_epilepsy",1);
7048 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7049 }
7050 return D_O_K;
7051 }
7052
7053 bool rc = false;
7054
7055 static DIALOG getnum_dlg[] =
7056 {
7057 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7058 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7059 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7060 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7061 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7062 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7063 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7064 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7065 };
7066
7067 int32_t getnumber(const char *prompt,int32_t initialval)
7068 {
7069 char buf[20];
7070 sprintf(buf,"%d",initialval);
7071 getnum_dlg[0].dp=(void *)prompt;
7072 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7073 getnum_dlg[2].dp=buf;
7074
7075 large_dialog(getnum_dlg);
7076
7077 if(do_zqdialog(getnum_dlg,2)==3)
7078 return atoi(buf);
7079
7080 return initialval;
7081 }
7082
7083 int32_t onLife()
7084 {
7085 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7086 cheats_enqueue(Cheat::Life, value);
7087 return D_O_K;
7088 }
7089
7090 int32_t onHeartC()
7091 {
7092 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7093 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7094 cheats_enqueue(Cheat::MaxLife, max_life);
7095 cheats_enqueue(Cheat::Life, life);
7096 return D_O_K;
7097 }
7098
7099 int32_t onMagicC()
7100 {
7101 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7102 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7103 cheats_enqueue(Cheat::MaxMagic, max_magic);
7104 cheats_enqueue(Cheat::Magic, magic);
7105 return D_O_K;
7106 }
7107
7108 int32_t onRupies()
7109 {
7110 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7111 cheats_enqueue(Cheat::Rupies, value);
7112 return D_O_K;
7113 }
7114
7115 int32_t onMaxBombs()
7116 {
7117 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7118 cheats_enqueue(Cheat::MaxBombs, value);
7119 cheats_enqueue(Cheat::Bombs, value);
7120 return D_O_K;
7121 }
7122
7123 int32_t onRefillLife()
7124 {
7125 cheats_enqueue(Cheat::Life, game->get_maxlife());
7126 return D_O_K;
7127 }
7128 int32_t onRefillMagic()
7129 {
7130 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7131 return D_O_K;
7132 }
7133 int32_t onClock()
7134 {
7135 cheats_enqueue(Cheat::Clock);
7136 return D_O_K;
7137 }
7138
7139 int32_t onQstPath()
7140 {
7141 char path[2048];
7142
7143 chop_path(qstdir);
7144 strcpy(path,qstdir);
7145
7146 go();
7147
7148 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7149 {
7150 chop_path(path);
7151 fix_filename_case(path);
7152 fix_filename_slashes(path);
7153 strcpy(qstdir,path);
7154 strcpy(qstpath,qstdir);
7155 zc_set_config("zeldadx","quest_dir",qstdir);
7156 flush_config_file();
7157 }
7158
7159 comeback();
7160 return D_O_K;
7161 }
7162
7163 #include "dialog/cheat_dialog.h"
7164 int32_t onCheat()
7165 {
7166 call_setcheat_dialog();
7167 game->set_cheat(maxcheat);
7168 if(cheat) game->did_cheat(true);
7169 return D_O_K;
7170 }
7171
7172 int32_t onCheatRupies()
7173 {
7174 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7175 return D_O_K;
7176 }
7177
7178 int32_t onCheatArrows()
7179 {
7180 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7181 return D_O_K;
7182 }
7183
7184 int32_t onCheatBombs()
7185 {
7186 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7187 return D_O_K;
7188 }
7189
7190 // *** screen saver
7191
7192 18318213 int32_t after_time()
7193 {
7194
1/2
✓ Branch 0 taken 18318213 times.
✗ Branch 1 not taken.
18318213 if(ss_enable == 0)
7195 return INT_MAX;
7196
7197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
18318213 if(ss_after <= 0)
7198 return 5 * 60;
7199
7200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
18318213 if(ss_after <= 3)
7201 return ss_after * 15 * 60;
7202
7203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318213 times.
18318213 if(ss_after <= 13)
7204 return (ss_after - 3) * 60 * 60;
7205
7206 18318213 return MAX_IDLE + 1;
7207 18318213 }
7208
7209 static const char *after_str[15] =
7210 {
7211 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7212 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7213 "Never"
7214 };
7215
7216 const char *after_list(int32_t index, int32_t *list_size)
7217 {
7218 if(index < 0)
7219 {
7220 *list_size = 15;
7221 return NULL;
7222 }
7223
7224 return after_str[index];
7225 }
7226
7227 350 static ListData after__list(after_list, &font);
7228
7229 static DIALOG scrsaver_dlg[] =
7230 {
7231 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7232 350 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7233 350 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7234 350 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7235 350 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7236 350 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7237 350 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7238 350 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7239 350 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7240 350 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7241 350 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7242 350 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7243 350 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7244 350 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7245 };
7246
7247 int32_t onScreenSaver()
7248 {
7249 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7250 int32_t oldcfgs[3];
7251 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7252 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7253 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7254
7255 large_dialog(scrsaver_dlg);
7256
7257 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7258
7259 if(ret == 8 || ret == 9)
7260 {
7261 ss_after = scrsaver_dlg[5].d1;
7262 ss_speed = scrsaver_dlg[6].d2;
7263 ss_density = scrsaver_dlg[7].d2;
7264 if(oldcfgs[0] != ss_after)
7265 zc_set_config(cfg_sect,"ss_after",ss_after);
7266 if(oldcfgs[1] != ss_speed)
7267 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7268 if(oldcfgs[2] != ss_density)
7269 zc_set_config(cfg_sect,"ss_density",ss_density);
7270 }
7271
7272 if(ret == 9)
7273 // preview Screen Saver
7274 {
7275 clear_keybuf();
7276 Matrix(ss_speed, ss_density, 30);
7277 system_pal(true);
7278 sys_mouse();
7279 }
7280
7281 return D_O_K;
7282 }
7283
7284 /***** Menus *****/
7285
7286 enum
7287 {
7288 MENUID_GAME_LOADQUEST,
7289 MENUID_GAME_ENDGAME,
7290 };
7291
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu game_menu
7292 2800 {
7293
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "&Continue","ESC", onContinue },
7294
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7295
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "L&oad Quest...", onCustomGame, MENUID_GAME_LOADQUEST },
7296
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "&End Game","F6", onTryQuitMenu, MENUID_GAME_ENDGAME },
7297
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7298 #ifdef __EMSCRIPTEN__
7299 { "&Reset","F7", onReset },
7300 #elif defined(ALLEGRO_MACOSX)
7301 { "&Reset","F7", onReset },
7302 { "&Quit","F8", onExit },
7303 #else
7304
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "&Reset","F9", onReset },
7305
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "&Quit","F10", onExit },
7306 #endif
7307 };
7308
7309
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu snapshot_format_menu
7310 2450 {
7311
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "&BMP", std::bind(onSetSnapshotFormat, ssfmtBMP) },
7312
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "&GIF", std::bind(onSetSnapshotFormat, ssfmtGIF) },
7313
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "&JPG", std::bind(onSetSnapshotFormat, ssfmtJPG) },
7314
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "&PNG", std::bind(onSetSnapshotFormat, ssfmtPNG) },
7315
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "PC&X", std::bind(onSetSnapshotFormat, ssfmtPCX) },
7316
4/8
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 350 times.
✗ Branch 7 not taken.
350 { "&TGA", std::bind(onSetSnapshotFormat, ssfmtTGA) },
7317 };
7318
7319
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu controls_menu
7320 1400 {
7321
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Key&board...", onKeyboard },
7322
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Gamepad...", onGamepad },
7323
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Cheat Keys...", onCheatKeys },
7324 };
7325
7326
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu name_entry_mode_menu
7327 1400 {
7328
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Keyboard", onKeyboardEntry },
7329
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Letter Grid", onLetterGridEntry },
7330
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Extended Letter Grid", onExtLetterGridEntry },
7331 };
7332
7333 static void set_controls_menu_active()
7334 {
7335
7336 }
7337
7338 enum
7339 {
7340 MENUID_WINDOW_LOCK_ASPECT,
7341 MENUID_WINDOW_LOCK_INTSCALE,
7342 MENUID_WINDOW_SAVE_SIZE,
7343 MENUID_WINDOW_SAVE_POS,
7344 MENUID_WINDOW_STRETCH,
7345 };
7346
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu window_menu
7347 2100 {
7348
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Lock Aspect Ratio", onDragAspect, MENUID_WINDOW_LOCK_ASPECT },
7349
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Lock Integer Scale", onIntegerScaling, MENUID_WINDOW_LOCK_INTSCALE },
7350
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Save Size Changes", onSaveDragResize, MENUID_WINDOW_SAVE_SIZE },
7351
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Save Position Changes", onWinPosSave, MENUID_WINDOW_SAVE_POS },
7352
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Stretch Game Area", onStretchGame, MENUID_WINDOW_STRETCH },
7353 };
7354 void call_zc_options_dlg();
7355 enum
7356 {
7357 MENUID_OPTIONS_PAUSE_BG,
7358 MENUID_OPTIONS_EPILEPSYPROT,
7359 };
7360
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu options_menu
7361 2450 {
7362
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Name &Entry Mode", &name_entry_mode_menu },
7363
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "S&napshot Format", &snapshot_format_menu },
7364
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Window Settings", &window_menu },
7365
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Epilepsy Flash Reduction", onEpilepsy, MENUID_OPTIONS_EPILEPSYPROT },
7366
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Pause In Background", onPauseInBackground, MENUID_OPTIONS_PAUSE_BG },
7367
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "More Options", call_zc_options_dlg },
7368 };
7369 enum
7370 {
7371 MENUID_SETTINGS_CONTROLS,
7372 MENUID_SETTINGS_CAPFPS,
7373 MENUID_SETTINGS_SHOWFPS,
7374 MENUID_SETTINGS_SHOWTIME,
7375 MENUID_SETTINGS_CLICK_FREEZE,
7376 MENUID_SETTINGS_TRANSLAYERS,
7377 MENUID_SETTINGS_NESQUIT,
7378 MENUID_SETTINGS_VOLKEYS,
7379 MENUID_SETTINGS_HEARTBEEP,
7380 MENUID_SETTINGS_SAVEINDICATOR,
7381 MENUID_SETTINGS_DEBUG,
7382 };
7383
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu settings_menu
7384 5950 {
7385
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Sound...", onSound },
7386
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "C&ontrols", &controls_menu, MENUID_SETTINGS_CONTROLS },
7387
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7388
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Options", &options_menu },
7389
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7390
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "&Cap FPS","F1", onThrottleFPS, MENUID_SETTINGS_CAPFPS },
7391
3/6
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 350 times.
✗ Branch 5 not taken.
350 { "Show &FPS","F2", onShowFPS, MENUID_SETTINGS_SHOWFPS },
7392
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Show &Time", onShowTime, MENUID_SETTINGS_SHOWTIME },
7393
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Click to Freeze", onClickToFreeze, MENUID_SETTINGS_CLICK_FREEZE },
7394
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Cont. &Heart Beep", onHeartBeep, MENUID_SETTINGS_HEARTBEEP },
7395
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Show Trans. &Layers", onTransLayers, MENUID_SETTINGS_TRANSLAYERS },
7396
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Up+A+B To &Quit", onNESquit, MENUID_SETTINGS_NESQUIT },
7397
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Volume &Keys", onVolKeys, MENUID_SETTINGS_VOLKEYS },
7398
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Sa&ve Indicator", onSaveIndicator, MENUID_SETTINGS_SAVEINDICATOR },
7399
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7400
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Debu&g", onDebug, MENUID_SETTINGS_DEBUG },
7401 };
7402
7403 enum
7404 {
7405 MENUID_MISC_FULLSCREEN,
7406 MENUID_MISC_VIDMODE,
7407 MENUID_MISC_QUEST_INFO,
7408 MENUID_MISC_QUEST_DIR,
7409 MENUID_MISC_ZASM_DEBUGGER,
7410 MENUID_MISC_ZSCRIPT_DEBUGGER,
7411 MENUID_MISC_CLEAR_CONSOLE_ON_LOAD,
7412 };
7413
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu misc_menu
7414 5250 {
7415
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&About...", onAbout },
7416 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7417 // { "&Credits...", onCredits },
7418
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Fullscreen", onFullscreenMenu, MENUID_MISC_FULLSCREEN },
7419
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Video Mode...", onVidMode, MENUID_MISC_VIDMODE },
7420
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7421
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Quest Info...", onQuest, MENUID_MISC_QUEST_INFO },
7422
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Quest &MIDI Info...", onMIDICredits },
7423
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Quest &Directory...", onQstPath, MENUID_MISC_QUEST_DIR },
7424
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7425
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Take &Snapshot F12", onSnapshot },
7426
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Sc&reen Saver...", onScreenSaver },
7427
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Save ZC Configuration", OnSaveZCConfig },
7428
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Show ZScript Debugger", onConsoleZScript, MENUID_MISC_ZSCRIPT_DEBUGGER },
7429
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Clear Console on Qst Load", onClrConsoleOnLoad, MENUID_MISC_CLEAR_CONSOLE_ON_LOAD },
7430
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Clear Directory Cache", OnnClearQuestDir },
7431 };
7432
7433 enum
7434 {
7435 MENUID_REFILL_ARROWS,
7436 };
7437
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu refill_menu
7438 2100 {
7439
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Life", onRefillLife },
7440
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Magic", onRefillMagic },
7441
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Bombs", onCheatBombs },
7442
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Rupees", onCheatRupies },
7443
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Arrows", onCheatArrows, MENUID_REFILL_ARROWS },
7444 };
7445
7446 enum
7447 {
7448 MENUID_SHOW_L0,
7449 MENUID_SHOW_L1,
7450 MENUID_SHOW_L2,
7451 MENUID_SHOW_L3,
7452 MENUID_SHOW_L4,
7453 MENUID_SHOW_L5,
7454 MENUID_SHOW_L6,
7455 MENUID_SHOW_OVER,
7456 MENUID_SHOW_PUSH,
7457 MENUID_SHOW_FFC,
7458 MENUID_SHOW_SPR,
7459 MENUID_SHOW_SCRIPTNAME,
7460 MENUID_SHOW_SOLIDITY,
7461 MENUID_SHOW_HITBOX,
7462 MENUID_SHOW_EFFECT,
7463 };
7464
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu show_menu
7465 6650 {
7466
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Combos", onShowLayer0, MENUID_SHOW_L0 },
7467
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 1", onShowLayer1, MENUID_SHOW_L1 },
7468
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 2", onShowLayer2, MENUID_SHOW_L2 },
7469
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 3", onShowLayer3, MENUID_SHOW_L3 },
7470
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 4", onShowLayer4, MENUID_SHOW_L4 },
7471
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 5", onShowLayer5, MENUID_SHOW_L5 },
7472
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Layer 6", onShowLayer6, MENUID_SHOW_L6 },
7473
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Overhead Combos", onShowLayerO, MENUID_SHOW_OVER },
7474
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Push Blocks", onShowLayerP, MENUID_SHOW_PUSH },
7475
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Freeform Combos", onShowLayerF, MENUID_SHOW_FFC },
7476
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Sprites", onShowLayerS, MENUID_SHOW_SPR },
7477
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7478
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Current FFC Scripts", onShowFFScripts, MENUID_SHOW_SCRIPTNAME },
7479
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 {},
7480
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Walkability", onShowLayerW, MENUID_SHOW_SOLIDITY },
7481
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Hitboxes", onShowHitboxes, MENUID_SHOW_HITBOX },
7482
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Effects", onShowLayerE, MENUID_SHOW_EFFECT },
7483
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Info Opacity", onShowInfoOpacity },
7484 };
7485
7486 enum
7487 {
7488 MENUID_CHEAT_CHOP_L1,
7489 MENUID_CHEAT_CHOP_L2,
7490 MENUID_CHEAT_CHOP_L3,
7491 MENUID_CHEAT_CHOP_L4,
7492 MENUID_CHEAT_INVULN,
7493 MENUID_CHEAT_NOCLIP,
7494 MENUID_CHEAT_IGNORESV,
7495 MENUID_CHEAT_GOFAST,
7496 };
7497
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 static NewMenu cheat_menu
7498 5950 {
7499
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Set &Cheat", onCheat },
7500
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 { MENUID_CHEAT_CHOP_L1 },
7501
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Re&fill", &refill_menu },
7502
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 { MENUID_CHEAT_CHOP_L2 },
7503
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Invincible", onClock, MENUID_CHEAT_INVULN },
7504
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Ma&x Bombs...", onMaxBombs },
7505
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Heart Containers...", onHeartC },
7506
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Magic Containers...", onMagicC },
7507
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 { MENUID_CHEAT_CHOP_L3 },
7508
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Player Data...", onCheatConsole },
7509
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 { MENUID_CHEAT_CHOP_L4 },
7510
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Walk Through &Walls", onNoWalls, MENUID_CHEAT_NOCLIP },
7511
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Player Ignores Side&view", onIgnoreSideview, MENUID_CHEAT_IGNORESV },
7512
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Quick Movement", onGoFast, MENUID_CHEAT_GOFAST },
7513
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Kill All Enemies", onKillCheat },
7514
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Trigger &Secrets", onSecretsCheat },
7515
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Trigger Secrets Perm", onSecretsCheatPerm },
7516
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Show/Hide Layer", &show_menu },
7517
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "Toggle &Light", onLightSwitch },
7518
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Goto Location...", onGoTo },
7519 };
7520
7521 #if DEVLEVEL > 0
7522 int32_t devLogging();
7523 int32_t devDebug();
7524 int32_t devTimestmp();
7525 #if DEVLEVEL > 1
7526 int32_t setCheat();
7527 #endif //DEVLEVEL > 1
7528 enum
7529 {
7530 MENUID_DEV_LOGGING,
7531 MENUID_DEV_DEBUG,
7532 MENUID_DEV_TIMESTAMP,
7533 MENUID_DEV_SETCHEAT,
7534 };
7535 static NewMenu dev_menu
7536 {
7537 { "&Force Error Log", devLogging, MENUID_DEV_LOGGING },
7538 // { "&Extra Debug Log", devDebug, MENUID_DEV_DEBUG },
7539 { "&Timestamp Log", devTimestmp, MENUID_DEV_TIMESTAMP },
7540 #if DEVLEVEL > 1
7541 {},
7542 { "Set &Cheat", setCheat, MENUID_DEV_SETCHEAT },
7543 #endif //DEVLEVEL > 1
7544 };
7545 int32_t devLogging()
7546 {
7547 dev_logging = !dev_logging;
7548 dev_menu.select_uid(MENUID_DEV_LOGGING, dev_logging);
7549 return D_O_K;
7550 }
7551 // int32_t devDebug()
7552 // {
7553 // dev_debug = !dev_debug;
7554 // dev_menu.select_uid(MENUID_DEV_DEBUG, dev_debug);
7555 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7556 // return D_O_K;
7557 // }
7558 int32_t devTimestmp()
7559 {
7560 dev_timestmp = !dev_timestmp;
7561 dev_menu.select_uid(MENUID_DEV_TIMESTAMP, dev_timestmp);
7562 return D_O_K;
7563 }
7564 #if DEVLEVEL > 1
7565 int32_t setCheat()
7566 {
7567 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7568 return D_O_K;
7569 }
7570 #endif //DEVLEVEL > 1
7571 #endif //DEVLEVEL > 0
7572
7573 enum
7574 {
7575 MENUID_PLAYER_CHEAT,
7576 };
7577
1/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 TopMenu the_player_menu
7578 2100 {
7579
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Game", &game_menu },
7580
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Settings", &settings_menu },
7581
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Cheat", &cheat_menu, MENUID_PLAYER_CHEAT, true },
7582
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&Replay", &replay_menu },
7583
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
350 { "&ZC", &misc_menu },
7584 #if DEVLEVEL > 0
7585 { "&Dev", &dev_menu },
7586 #endif
7587 };
7588
7589 int32_t onPauseInBackground()
7590 {
7591 if(jwin_alert3(
7592 "Toggle Pause In Background",
7593 "This action will change whether ZC Player pauses when the window loses focus.",
7594 "",
7595 "Proceed?",
7596 "&Yes",
7597 "&No",
7598 NULL,
7599 'y',
7600 'n',
7601 0,
7602 get_zc_font(font_lfont)) == 1)
7603 {
7604 pause_in_background = pause_in_background ? 0 : 1;
7605 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7606 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7607 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7608 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7609 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7610 }
7611 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7612 return D_O_K;
7613 }
7614
7615 int32_t onKeyboardEntry()
7616 {
7617 NameEntryMode=0;
7618 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7619 return D_O_K;
7620 }
7621
7622 int32_t onLetterGridEntry()
7623 {
7624 NameEntryMode=1;
7625 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7626 return D_O_K;
7627 }
7628
7629 int32_t onExtLetterGridEntry()
7630 {
7631 NameEntryMode=2;
7632 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7633 return D_O_K;
7634 }
7635
7636 static BITMAP* oldscreen;
7637 int32_t onFullscreenMenu()
7638 {
7639 PALETTE oldpal;
7640 get_palette(oldpal);
7641
7642 fullscreen = !fullscreen;
7643 all_toggle_fullscreen(fullscreen);
7644 zc_set_config("zeldadx","fullscreen",fullscreen);
7645
7646 zc_set_palette(oldpal);
7647 gui_mouse_focus=0;
7648 extern int32_t switch_type;
7649 switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7650 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7651 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7652 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7653 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7654 misc_menu.select_uid(MENUID_MISC_VIDMODE, isFullScreen());
7655
7656 return D_O_K;
7657 }
7658
7659 262 void fix_menu()
7660 {
7661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262 times.
262 if(!debug_enabled)
7662 262 settings_menu.chop_index = 13;
7663 262 }
7664
7665 int32_t onSetSnapshotFormat(SnapshotType format)
7666 {
7667 SnapshotFormat = format;
7668 zc_set_config("zeldadx", "snapshot_format", format);
7669 snapshot_format_menu.select_only_index(format);
7670 return D_O_K;
7671 }
7672
7673
7674 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7675 {
7676 PALETTE tmp;
7677
7678 for(int32_t i=0; i<256; i++)
7679 {
7680 tmp[i].r=r;
7681 tmp[i].g=g;
7682 tmp[i].b=b;
7683 }
7684
7685 fade_interpolate(src,tmp,dest,pos,from,to);
7686 }
7687
7688 88 void system_pal(bool force)
7689 {
7690
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
88 if(is_sys_pal && !force) return;
7691 88 is_sys_pal = true;
7692 88 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7693 88 hw_palette = &syspal;
7694 88 update_hw_pal = true;
7695 88 }
7696
7697 static uint32_t entered_sys_pal = 0;
7698 88 void enter_sys_pal()
7699 {
7700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(is_sys_pal)
7701 {
7702 if(entered_sys_pal)
7703 ++entered_sys_pal;
7704 return;
7705 }
7706 88 sys_mouse();
7707 88 system_pal(true);
7708 88 ++entered_sys_pal;
7709 88 }
7710 88 void exit_sys_pal()
7711 {
7712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(entered_sys_pal)
7713 {
7714
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!--entered_sys_pal)
7715 {
7716 88 game_pal();
7717 88 game_mouse();
7718 88 }
7719 88 }
7720 88 }
7721
7722 void switch_out_callback()
7723 {
7724 if (pause_in_background && !MenuOpen)
7725 {
7726 System();
7727 }
7728 }
7729
7730 void switch_in_callback()
7731 {
7732 }
7733
7734 1138 void game_pal()
7735 {
7736 1138 is_sys_pal = false;
7737 1138 entered_sys_pal = 0;
7738 1138 hw_palette = &RAMpal;
7739 1138 update_hw_pal = true;
7740 1138 }
7741
7742 static char bar_str[] = "";
7743
7744 61 void music_pause()
7745 {
7746 //al_pause_duh(tmplayer);
7747 61 zcmusic_pause(zcmusic, ZCM_PAUSE);
7748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(zcmixer->oldtrack)
7749 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7750 61 zc_midi_pause();
7751 61 }
7752
7753 void music_resume()
7754 {
7755 //al_resume_duh(tmplayer);
7756 zcmusic_pause(zcmusic, ZCM_RESUME);
7757 if (zcmixer->oldtrack)
7758 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7759 zc_midi_resume();
7760 }
7761
7762 7612 void music_stop()
7763 {
7764 //al_stop_duh(tmplayer);
7765 //unload_duh(tmusic);
7766 //tmusic=NULL;
7767 //tmplayer=NULL;
7768 7612 zcmusic_stop(zcmusic);
7769 7612 zcmusic_unload_file(zcmusic);
7770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7612 times.
7612 if (zcmixer->oldtrack)
7771 {
7772 zcmusic_stop(zcmixer->oldtrack);
7773 zcmusic_unload_file(zcmixer->oldtrack);
7774 }
7775 7612 zcmixer->newtrack = NULL;
7776 7612 zc_stop_midi();
7777 7612 currmidi=-1;
7778 7612 }
7779
7780 bool reload_fonts = false;
7781 void System()
7782 {
7783 mouse_down = gui_mouse_b();
7784 music_pause();
7785 pause_all_sfx();
7786 MenuOpen = true;
7787 enter_sys_pal();
7788 // FONT *oldfont=font;
7789 // font=tfont;
7790
7791 misc_menu.select_uid(MENUID_MISC_FULLSCREEN, isFullScreen());
7792 misc_menu.disable_uid(MENUID_MISC_VIDMODE, isFullScreen());
7793
7794 #if DEVLEVEL > 1
7795 dev_menu.disable_uid(MENUID_DEV_SETCHEAT, !Playing);
7796 #endif
7797 game_menu.disable_uid(MENUID_GAME_LOADQUEST, getsaveslot() < 0);
7798 game_menu.disable_uid(MENUID_GAME_ENDGAME, !Playing);
7799 misc_menu.disable_uid(MENUID_MISC_QUEST_INFO, !Playing);
7800 misc_menu.disable_uid(MENUID_MISC_QUEST_DIR, Playing);
7801 clear_keybuf();
7802
7803 clear_bitmap(menu_bmp);
7804 oldscreen = screen;
7805 screen = menu_bmp;
7806
7807 the_player_menu.reset_state();
7808 the_player_menu.position(0, 0);
7809
7810 bool running = true;
7811 bool esc = key[KEY_ESC] || cMbtn();
7812 bool autopop = esc;
7813 do
7814 {
7815 if(reload_fonts)
7816 {
7817 init_custom_fonts();
7818 clear_bitmap(menu_bmp);
7819 broadcast_dialog_message(MSG_DRAW, 0);
7820 reload_fonts = false;
7821 }
7822 if(handle_close_btn_quit())
7823 break;
7824
7825 //update submenus
7826 {
7827 settings_menu.disable_uid(MENUID_SETTINGS_CONTROLS, replay_is_replaying());
7828 settings_menu.select_uid(MENUID_SETTINGS_CAPFPS, Throttlefps);
7829 settings_menu.select_uid(MENUID_SETTINGS_SHOWFPS, ShowFPS);
7830 settings_menu.select_uid(MENUID_SETTINGS_SHOWTIME, ShowGameTime);
7831 settings_menu.select_uid(MENUID_SETTINGS_CLICK_FREEZE, ClickToFreeze);
7832 settings_menu.select_uid(MENUID_SETTINGS_TRANSLAYERS, TransLayers);
7833 settings_menu.select_uid(MENUID_SETTINGS_NESQUIT, NESquit);
7834 settings_menu.select_uid(MENUID_SETTINGS_VOLKEYS, volkeys);
7835
7836 window_menu.select_uid(MENUID_WINDOW_LOCK_ASPECT, DragAspect);
7837 window_menu.select_uid(MENUID_WINDOW_LOCK_INTSCALE, scaleForceInteger);
7838 window_menu.select_uid(MENUID_WINDOW_SAVE_SIZE, SaveDragResize);
7839 window_menu.select_uid(MENUID_WINDOW_SAVE_POS, SaveWinPos);
7840 window_menu.select_uid(MENUID_WINDOW_STRETCH, stretchGame);
7841
7842 options_menu.select_uid(MENUID_OPTIONS_EPILEPSYPROT, epilepsyFlashReduction);
7843 options_menu.select_uid(MENUID_OPTIONS_PAUSE_BG, pause_in_background);
7844
7845 name_entry_mode_menu.select_only_index(NameEntryMode);
7846
7847 misc_menu.select_uid(MENUID_MISC_ZASM_DEBUGGER, zasm_debugger);
7848 misc_menu.select_uid(MENUID_MISC_ZSCRIPT_DEBUGGER, zscript_debugger);
7849 misc_menu.select_uid(MENUID_MISC_CLEAR_CONSOLE_ON_LOAD, clearConsoleOnLoad);
7850
7851 bool nocheat = (replay_is_replaying() || !Playing
7852 || (!maxcheat && !zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7853 the_player_menu.disable_uid(MENUID_PLAYER_CHEAT, nocheat);
7854 refill_menu.disable_uid(MENUID_REFILL_ARROWS, !get_qr(qr_TRUEARROWS));
7855 cheat_menu.chop_index.reset();
7856 if(cheat < 4)
7857 cheat_menu.chop_index = cheat_menu.ind_at(MENUID_CHEAT_CHOP_L1+cheat);
7858 cheat_menu.select_uid(MENUID_CHEAT_INVULN, getClock());
7859 cheat_menu.select_uid(MENUID_CHEAT_NOCLIP, toogam);
7860 cheat_menu.select_uid(MENUID_CHEAT_IGNORESV, ignoreSideview);
7861 cheat_menu.select_uid(MENUID_CHEAT_GOFAST, gofast);
7862
7863 show_menu.select_uid(MENUID_SHOW_L0, show_layer_0);
7864 show_menu.select_uid(MENUID_SHOW_L1, show_layer_1);
7865 show_menu.select_uid(MENUID_SHOW_L2, show_layer_2);
7866 show_menu.select_uid(MENUID_SHOW_L3, show_layer_3);
7867 show_menu.select_uid(MENUID_SHOW_L4, show_layer_4);
7868 show_menu.select_uid(MENUID_SHOW_L5, show_layer_5);
7869 show_menu.select_uid(MENUID_SHOW_L6, show_layer_6);
7870 show_menu.select_uid(MENUID_SHOW_OVER, show_layer_over);
7871 show_menu.select_uid(MENUID_SHOW_PUSH, show_layer_push);
7872 show_menu.select_uid(MENUID_SHOW_SPR, show_sprites);
7873 show_menu.select_uid(MENUID_SHOW_FFC, show_ffcs);
7874 show_menu.select_uid(MENUID_SHOW_SOLIDITY, show_walkflags);
7875 show_menu.select_uid(MENUID_SHOW_SCRIPTNAME, show_ff_scripts);
7876 show_menu.select_uid(MENUID_SHOW_HITBOX, show_hitboxes);
7877 show_menu.select_uid(MENUID_SHOW_EFFECT, show_effectflags);
7878
7879 settings_menu.select_uid(MENUID_SETTINGS_HEARTBEEP, heart_beep);
7880 settings_menu.select_uid(MENUID_SETTINGS_SAVEINDICATOR, use_save_indicator);
7881
7882 replay_menu.by_uid(MENUID_REPLAY_STOP)->text = fmt::format("Stop {}",
7883 replay_get_mode() == ReplayMode::Record ? "recording" : "replaying");
7884
7885 replay_menu.select_uid(MENUID_REPLAY_RECORDNEW, zc_get_config("zeldadx", "replay_new_saves", false));
7886 replay_menu.disable_uid(MENUID_REPLAY_STOP, !replay_is_active());
7887 replay_menu.disable_uid(MENUID_REPLAY_SAVE, replay_get_mode() != ReplayMode::Record);
7888 replay_menu.select_uid(MENUID_REPLAY_SNAP_ALL, replay_is_snapshot_all_frames());
7889
7890 snapshot_format_menu.select_only_index(SnapshotFormat);
7891 }
7892
7893 if(debug_enabled)
7894 settings_menu.select_uid(MENUID_SETTINGS_DEBUG, get_debug());
7895
7896 if(autopop)
7897 clear_keybuf();
7898 the_player_menu.run(true);
7899 if(autopop)
7900 {
7901 the_player_menu.pop_sub(0, &the_player_menu);
7902 the_player_menu.draw(screen, the_player_menu.hovered_ind());
7903 autopop = false;
7904 update_hw_screen(true);
7905 }
7906
7907 update_hw_screen();
7908 throttleFPS(60);
7909
7910 auto mb = gui_mouse_b();
7911 if(XOR(mb, mouse_down))
7912 {
7913 if(!the_player_menu.has_mouse())
7914 if(mb)
7915 break;
7916 mouse_down = mb;
7917 }
7918
7919 if(input_idle(true) > after_time())
7920 // run Screeen Saver
7921 {
7922 // Screen saver enabled for now.
7923 clear_keybuf();
7924 Matrix(ss_speed, ss_density, 0);
7925 system_pal(true);
7926 sys_mouse();
7927 }
7928
7929 poll_keyboard();
7930 if(esc)
7931 {
7932 if(!key[KEY_ESC])
7933 esc = false;
7934 }
7935
7936 if(keypressed() && !CHECK_ALT) //System hotkeys
7937 {
7938 auto c = peekkey();
7939 bool eatkey = true;
7940 switch(c>>8)
7941 {
7942 //Spare keys used by the menu
7943 case KEY_UP:
7944 case KEY_DOWN:
7945 case KEY_LEFT:
7946 case KEY_RIGHT:
7947 eatkey = false;
7948 break;
7949 case KEY_F1:
7950 onThrottleFPS();
7951 break;
7952 case KEY_F2:
7953 onShowFPS();
7954 break;
7955 case KEY_F6:
7956 onTryQuitMenu();
7957 break;
7958 #ifndef ALLEGRO_MACOSX
7959 case KEY_F9:
7960 onReset();
7961 break;
7962 case KEY_F10:
7963 onExit();
7964 break;
7965 #else
7966 case KEY_F7:
7967 onReset();
7968 break;
7969 case KEY_F8:
7970 onExit();
7971 break;
7972 #endif
7973 case KEY_F12:
7974 onSnapshot();
7975 break;
7976 case KEY_TAB:
7977 onDebug();
7978 break;
7979 case KEY_ESC:
7980 if(!esc)
7981 running = false;
7982 break;
7983 }
7984 if(eatkey)
7985 readkey();
7986 }
7987 if(Quit || (GameFlags & GAMEFLAG_TRYQUIT))
7988 break;
7989 }
7990 while(running);
7991
7992 screen = oldscreen;
7993
7994 mouse_down=gui_mouse_b();
7995 MenuOpen = false;
7996 if(Quit)
7997 {
7998 kill_sfx();
7999 music_stop();
8000 update_hw_screen();
8001 }
8002 else
8003 {
8004 music_resume();
8005 resume_all_sfx();
8006
8007 if(rc)
8008 ringcolor(false);
8009 }
8010 exit_sys_pal();
8011
8012 eat_buttons();
8013
8014 rc=false;
8015 clear_keybuf();
8016
8017 zc_init_apply_cheat_delta();
8018 }
8019
8020 262 void fix_dialogs()
8021 {
8022 262 jwin_center_dialog(about_dlg);
8023 262 jwin_center_dialog(gamepad_dlg);
8024 262 jwin_center_dialog(credits_dlg);
8025 262 jwin_center_dialog(gamemode_dlg);
8026 262 jwin_center_dialog(getnum_dlg);
8027 262 jwin_center_dialog(goto_dlg);
8028 262 jwin_center_dialog(keyboard_control_dlg);
8029 262 jwin_center_dialog(midi_dlg);
8030 262 jwin_center_dialog(quest_dlg);
8031 262 jwin_center_dialog(scrsaver_dlg);
8032 262 jwin_center_dialog(sound_dlg);
8033 262 jwin_center_dialog(triforce_dlg);
8034 262 }
8035
8036 /*****************************/
8037 /**** Custom Sound System ****/
8038 /*****************************/
8039
8040 4328 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8041 {
8042
3/4
✓ Branch 0 taken 4328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4280 times.
✓ Branch 3 taken 48 times.
4328 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8043 }
8044
8045 290 int32_t get_emusic_volume()
8046 {
8047 290 int32_t temp_volume = emusic_volume;
8048
2/4
✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✗ Branch 3 not taken.
290 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8049 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 if (!zcmusic)
8051 290 return temp_volume;
8052 return (temp_volume * zcmusic->fadevolume) / 10000;
8053 290 }
8054
8055 int32_t get_zcmusicpos()
8056 {
8057 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8058 return debugtracething;
8059 return 0;
8060 }
8061
8062 void set_zcmusicpos(int32_t position)
8063 {
8064 zcmusic_set_curpos(zcmusic, position);
8065 }
8066
8067 void set_zcmusicspeed(int32_t speed)
8068 {
8069 zcmusic_set_speed(zcmusic, speed);
8070 }
8071
8072 int32_t get_zcmusiclen()
8073 {
8074 return zcmusic_get_length(zcmusic);
8075 }
8076
8077 3 void set_zcmusicloop(double start, double end)
8078 {
8079 3 zcmusic_set_loop(zcmusic, start, end);
8080 3 }
8081
8082 64182 void jukebox(int32_t index,int32_t loop)
8083 {
8084
2/2
✓ Branch 0 taken 64156 times.
✓ Branch 1 taken 26 times.
64182 if (is_headless())
8085 64156 return;
8086
8087 26 music_stop();
8088
8089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(index<0) index=MAXMIDIS-1;
8090
8091
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(index>=MAXMIDIS) index=0;
8092
8093 26 music_stop();
8094
8095 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8096 // stuck notes when a song stops. This fixes it.
8097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(strcmp(midi_driver->name, "DIGMID")==0)
8098 zc_set_volume(0, 0);
8099
8100 26 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8101 26 zc_play_midi((MIDI*)tunes[index].data,loop);
8102
8103
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(tunes[index].start>0)
8104 zc_midi_seek(tunes[index].start);
8105
8106 26 midi_loop_start = tunes[index].loop_start;
8107 26 midi_loop_end = tunes[index].loop_end;
8108
8109 26 currmidi=index;
8110 26 master_volume(digi_volume, midi_volume);
8111 //midi_paused=false;
8112 64182 }
8113
8114 64193 void jukebox(int32_t index)
8115 {
8116
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index<0) index=MAXMIDIS-1;
8117
8118
1/2
✓ Branch 0 taken 64193 times.
✗ Branch 1 not taken.
64193 if(index>=MAXMIDIS) index=0;
8119
8120 // do nothing if it's already playing
8121
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 64182 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
64193 if(index==currmidi && midi_pos>=0)
8122 {
8123 11 return;
8124 }
8125
8126 64182 jukebox(index,tunes[index].loop);
8127 64193 }
8128
8129 160 void play_DmapMusic()
8130 {
8131
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 60 times.
160 if (is_headless())
8132 100 return;
8133
8134 static char tfile[2048];
8135 static int32_t ttrack=0;
8136 60 bool domidi=false;
8137
8138 60 int32_t fadeoutframes = 0;
8139
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (zcmusic != NULL)
8140 fadeoutframes = zcmusic->fadeoutframes;
8141
8142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(DMaps[currdmap].tmusic[0]!=0)
8143 {
8144 if(zcmusic==NULL ||
8145 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8146 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8147 {
8148 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8149 {
8150 if (play_enh_music_crossfade(DMaps[currdmap].tmusic, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8151 {
8152 if (zcmusic != NULL)
8153 {
8154 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8155 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8156 }
8157 }
8158 }
8159 else
8160 {
8161 if (zcmusic != NULL)
8162 {
8163 zcmusic_stop(zcmusic);
8164 zcmusic_unload_file(zcmusic);
8165 zcmusic = NULL;
8166 zcmixer->newtrack = NULL;
8167 }
8168
8169 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8170 zcmixer->newtrack = zcmusic;
8171
8172 if (zcmusic != NULL)
8173 {
8174 zc_stop_midi();
8175 strcpy(tfile, DMaps[currdmap].tmusic);
8176 zcmusic_play(zcmusic, emusic_volume);
8177 int32_t temptracks = 0;
8178 temptracks = zcmusic_get_tracks(zcmusic);
8179 temptracks = (temptracks < 2) ? 1 : temptracks;
8180 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8181 zcmusic_change_track(zcmusic, ttrack);
8182 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8183 }
8184 else
8185 {
8186 tfile[0] = 0;
8187 domidi = true;
8188 }
8189 }
8190 }
8191 }
8192 else
8193 {
8194
3/8
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8195 {
8196 play_enh_music_crossfade(NULL, qstpath, DMaps[currdmap].tmusictrack, get_emusic_volume(), DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8197 }
8198 else
8199 {
8200 60 domidi = true;
8201 }
8202 }
8203
8204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(domidi)
8205 {
8206 60 int32_t m=DMaps[currdmap].midi;
8207
8208
2/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 switch(m)
8209 {
8210 case 1:
8211 37 jukebox(ZC_MIDI_OVERWORLD);
8212 37 break;
8213
8214 case 2:
8215 jukebox(ZC_MIDI_DUNGEON);
8216 break;
8217
8218 case 3:
8219 jukebox(ZC_MIDI_LEVEL9);
8220 break;
8221
8222 default:
8223
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8224 jukebox(m+MIDIOFFSET_DMAP);
8225 else
8226 23 music_stop();
8227 23 }
8228 60 }
8229 160 }
8230
8231 34923 void playLevelMusic()
8232 {
8233
2/2
✓ Branch 0 taken 34863 times.
✓ Branch 1 taken 60 times.
34923 if (is_headless())
8234 34863 return;
8235
8236 60 int32_t m=tmpscr->screen_midi;
8237
8238
1/6
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
60 switch(m)
8239 {
8240 case -2:
8241 music_stop();
8242 break;
8243
8244 case -1:
8245 60 play_DmapMusic();
8246 60 break;
8247
8248 case 1:
8249 jukebox(ZC_MIDI_OVERWORLD);
8250 break;
8251
8252 case 2:
8253 jukebox(ZC_MIDI_DUNGEON);
8254 break;
8255
8256 case 3:
8257 jukebox(ZC_MIDI_LEVEL9);
8258 break;
8259
8260 default:
8261 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8262 jukebox(m+MIDIOFFSET_MAPSCR);
8263 else
8264 music_stop();
8265 }
8266 34923 }
8267
8268 4302 void master_volume(int32_t dv,int32_t mv)
8269 {
8270
7/8
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 2295 times.
✓ Branch 2 taken 1967 times.
✓ Branch 3 taken 328 times.
✓ Branch 4 taken 2295 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1967 times.
✓ Branch 7 taken 328 times.
4302 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8271
8272
7/8
✓ Branch 0 taken 2004 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 1998 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 2298 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1998 times.
✓ Branch 7 taken 300 times.
4302 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8273
8274
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 4276 times.
✓ Branch 2 taken 4302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 4276 times.
4302 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8275 4302 int32_t temp_vol = midi_volume;
8276
2/2
✓ Branch 0 taken 4040 times.
✓ Branch 1 taken 262 times.
4302 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8277 262 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8278 4302 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8279 4302 }
8280
8281 /*****************/
8282 /***** SFX *****/
8283 /*****************/
8284
8285 // array of voices, one for each sfx sample in the data file
8286 // 0+ = voice #
8287 // -1 = voice not allocated
8288 262 void Z_init_sound()
8289 {
8290
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 262 times.
67334 for(int32_t i=0; i<WAV_COUNT; i++)
8291 67072 sfx_voice[i]=-1;
8292
8293 262 const char* midis[ZC_MIDI_COUNT] = {
8294 "assets/dungeon.mid",
8295 "assets/ending.mid",
8296 "assets/gameover.mid",
8297 "assets/level9.mid",
8298 "assets/overworld.mid",
8299 "assets/title.mid",
8300 "assets/triforce.mid",
8301 };
8302
2/2
✓ Branch 0 taken 1834 times.
✓ Branch 1 taken 262 times.
2096 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8303 {
8304 1834 tunes[i].data = load_midi(midis[i]);
8305
1/2
✓ Branch 0 taken 1834 times.
✗ Branch 1 not taken.
1834 if (!tunes[i].data)
8306 Z_error_fatal("Missing required file %s\n", midis[i]);
8307 1834 }
8308
8309
2/2
✓ Branch 0 taken 66024 times.
✓ Branch 1 taken 262 times.
66286 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8310 66024 tunes[ZC_MIDI_COUNT+j].data=NULL;
8311
8312 262 master_volume(digi_volume,midi_volume);
8313 262 }
8314
8315 // returns number of voices currently allocated
8316 int32_t sfx_count()
8317 {
8318 int32_t c=0;
8319
8320 for(int32_t i=0; i<WAV_COUNT; i++)
8321 if(sfx_voice[i]!=-1)
8322 ++c;
8323
8324 return c;
8325 }
8326
8327 // clean up finished samples
8328 18109605 void sfx_cleanup()
8329 {
8330
2/2
✓ Branch 0 taken 4636058880 times.
✓ Branch 1 taken 18109605 times.
4654168485 for(int32_t i=0; i<WAV_COUNT; i++)
8331
3/4
✓ Branch 0 taken 1257107 times.
✓ Branch 1 taken 4634801773 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257107 times.
4637315987 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8332 {
8333 1257107 deallocate_voice(sfx_voice[i]);
8334 1257107 sfx_voice[i]=-1;
8335 1257107 }
8336 18109605 }
8337
8338 1257244 SAMPLE* sfx_get_sample(int32_t index)
8339 {
8340 // check index
8341
2/4
✓ Branch 0 taken 1257244 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1257244 times.
1257244 if (index<=0 || index>=WAV_COUNT)
8342 return nullptr;
8343
8344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257244 times.
1257244 if (sfxdat)
8345 {
8346 if (index<Z35)
8347 {
8348 return (SAMPLE*)sfxdata[index].dat;
8349 }
8350 else
8351 {
8352 return (SAMPLE*)sfxdata[Z35].dat;
8353 }
8354 }
8355 else
8356 {
8357 1257244 return &customsfxdata[index];
8358 }
8359
8360 return nullptr;
8361 1257244 }
8362
8363 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8364 // if a voice is already allocated (and/or playing), then it just returns true
8365 // Returns true: voice is allocated
8366 // false: unsuccessful
8367 1847442 bool sfx_init(int32_t index)
8368 {
8369 // check index
8370
3/4
✓ Branch 0 taken 1387854 times.
✓ Branch 1 taken 459588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1387854 times.
1847442 if(index<=0 || index>=WAV_COUNT)
8371 459588 return false;
8372
8373
2/2
✓ Branch 0 taken 130656 times.
✓ Branch 1 taken 1257198 times.
1387854 if (sfx_voice[index] == -1)
8374 {
8375 1257198 SAMPLE* sample = sfx_get_sample(index);
8376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1257198 times.
1257198 if (!sample)
8377 return false;
8378
8379 1257198 sfx_voice[index] = allocate_voice(sample);
8380 1257198 }
8381
8382 1387854 return sfx_voice[index] != -1;
8383 1847442 }
8384
8385 793 int32_t sfx_get_default_freq(int32_t index)
8386 {
8387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (sfxdat)
8388 {
8389 if (index < Z35)
8390 {
8391 return ((SAMPLE*)sfxdata[index].dat)->freq;
8392 }
8393 else
8394 {
8395 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8396 }
8397 }
8398 else
8399 {
8400 793 return customsfxdata[index].freq;
8401 }
8402 793 }
8403
8404 int32_t sfx_get_length(int32_t index)
8405 {
8406 if (sfxdat)
8407 {
8408 if (index < Z35)
8409 {
8410 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8411 }
8412 else
8413 {
8414 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8415 }
8416 }
8417 else
8418 {
8419 return int32_t(customsfxdata[index].len);
8420 }
8421 }
8422
8423 // plays an sfx sample
8424 1847309 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8425 {
8426
2/2
✓ Branch 0 taken 1387784 times.
✓ Branch 1 taken 459525 times.
1847309 if(!sfx_init(index))
8427 459525 return;
8428
2/2
✓ Branch 0 taken 1386991 times.
✓ Branch 1 taken 793 times.
1387784 if (!is_headless())
8429 {
8430 793 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8431 793 voice_set_pan(sfx_voice[index], pan);
8432
8433 // Only used by ZScript currently
8434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (freq <= -1)
8435 {
8436 793 freq = sfx_get_default_freq(index);
8437 793 }
8438 793 voice_set_frequency(sfx_voice[index], freq);
8439
8440 // Only used by ZScript currently
8441 793 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8442
2/4
✓ Branch 0 taken 793 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793 times.
✗ Branch 3 not taken.
793 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8443 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8444 793 voice_set_volume(sfx_voice[index], temp_volume);
8445
8446 793 int32_t pos = voice_get_position(sfx_voice[index]);
8447
8448
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 278 times.
793 if (restart) voice_set_position(sfx_voice[index], 0);
8449
8450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 793 times.
793 if (pos <= 0)
8451 793 voice_start(sfx_voice[index]);
8452 793 }
8453
8454
4/4
✓ Branch 0 taken 856065 times.
✓ Branch 1 taken 531719 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 856050 times.
1387784 if (restart && replay_is_debug())
8455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 856050 times.
856050 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8456 1847309 }
8457
8458 // true if sfx is allocated
8459 199119 bool sfx_allocated(int32_t index)
8460 {
8461
3/4
✓ Branch 0 taken 33965 times.
✓ Branch 1 taken 165154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33965 times.
199119 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8462 }
8463
8464 // start it (in loop mode) if it's not already playing,
8465 // otherwise adjust it to play in loop mode -DD
8466 116952 void cont_sfx(int32_t index)
8467 {
8468
2/2
✓ Branch 0 taken 116819 times.
✓ Branch 1 taken 133 times.
116952 if (is_headless())
8469 116819 return;
8470
8471
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 63 times.
133 if(!sfx_init(index))
8472 {
8473 63 return;
8474 }
8475
8476
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(voice_get_position(sfx_voice[index])<=0)
8477 {
8478 70 voice_set_position(sfx_voice[index],0);
8479 70 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8480 70 voice_set_volume(sfx_voice[index], sfx_volume);
8481 70 voice_start(sfx_voice[index]);
8482 70 }
8483 else
8484 {
8485 adjust_sfx(index, 128, true);
8486 }
8487 116952 }
8488
8489 // adjust parameters while playing
8490 6765 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8491 {
8492
4/6
✓ Branch 0 taken 4481 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 4481 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4481 times.
6765 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8493 6765 return;
8494
8495 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8496 voice_set_pan(sfx_voice[index],pan);
8497 6765 }
8498
8499 // pauses a voice
8500 3223 void pause_sfx(int32_t index)
8501 {
8502
3/6
✓ Branch 0 taken 3223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3223 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3223 times.
3223 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8503 voice_stop(sfx_voice[index]);
8504 3223 }
8505
8506 // resumes a voice
8507 1360 void resume_sfx(int32_t index)
8508 {
8509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (is_headless())
8510 1360 return;
8511
8512 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8513 voice_start(sfx_voice[index]);
8514 1360 }
8515
8516 // pauses all active voices
8517 1078 void pause_all_sfx()
8518 {
8519
2/2
✓ Branch 0 taken 275968 times.
✓ Branch 1 taken 1078 times.
277046 for(int32_t i=0; i<WAV_COUNT; i++)
8520
2/2
✓ Branch 0 taken 275966 times.
✓ Branch 1 taken 2 times.
275970 if(sfx_voice[i]!=-1)
8521 2 voice_stop(sfx_voice[i]);
8522 1078 }
8523
8524 // resumes all paused voices
8525 1017 void resume_all_sfx()
8526 {
8527
2/2
✓ Branch 0 taken 260352 times.
✓ Branch 1 taken 1017 times.
261369 for(int32_t i=0; i<WAV_COUNT; i++)
8528
1/2
✓ Branch 0 taken 260352 times.
✗ Branch 1 not taken.
260352 if(sfx_voice[i]!=-1)
8529 voice_start(sfx_voice[i]);
8530 1017 }
8531
8532 // stops an sfx and deallocates the voice
8533 14485531 void stop_sfx(int32_t index)
8534 {
8535
3/4
✓ Branch 0 taken 14238829 times.
✓ Branch 1 taken 246702 times.
✓ Branch 2 taken 14238829 times.
✗ Branch 3 not taken.
14485531 if(index<=0 || index>=WAV_COUNT)
8536 246702 return;
8537
8538
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14238796 times.
14238829 if(sfx_voice[index]!=-1)
8539 {
8540 33 deallocate_voice(sfx_voice[index]);
8541 33 sfx_voice[index]=-1;
8542 33 }
8543 14485531 }
8544
8545 // Stops SFX played by Hero's item of the given family
8546 130619 void stop_item_sfx(int32_t family)
8547 {
8548 130619 int32_t id=current_item_id(family);
8549
8550
2/2
✓ Branch 0 taken 129519 times.
✓ Branch 1 taken 1100 times.
130619 if(id<0)
8551 129519 return;
8552
8553 1100 stop_sfx(itemsbuf[id].usesound);
8554 130619 }
8555
8556 8001 void kill_sfx()
8557 {
8558
2/2
✓ Branch 0 taken 2048256 times.
✓ Branch 1 taken 8001 times.
2056257 for(int32_t i=0; i<WAV_COUNT; i++)
8559
2/2
✓ Branch 0 taken 2048200 times.
✓ Branch 1 taken 56 times.
2048312 if(sfx_voice[i]!=-1)
8560 {
8561 56 deallocate_voice(sfx_voice[i]);
8562 56 sfx_voice[i]=-1;
8563 56 }
8564 8001 }
8565
8566 1172503 int32_t pan(int32_t x)
8567 {
8568
1/4
✓ Branch 0 taken 1172503 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172503 switch(pan_style)
8569 {
8570 case 0:
8571 return 128;
8572
8573 case 1:
8574 1172503 return vbound((x>>1)+68,0,255);
8575
8576 case 2:
8577 return vbound(((x*3)>>2)+36,0,255);
8578 }
8579
8580 return vbound(x,0,255);
8581 1172503 }
8582
8583 /*******************************/
8584 /******* Input Handlers ********/
8585 /*******************************/
8586
8587 49874770 bool joybtn(int32_t b)
8588 {
8589
1/2
✓ Branch 0 taken 49874770 times.
✗ Branch 1 not taken.
49874770 if(b == 0)
8590 return false;
8591
1/2
✓ Branch 0 taken 49874770 times.
✗ Branch 1 not taken.
49874770 if (b-1 >= joy[joystick_index].num_buttons)
8592 49874770 return false;
8593
8594 return joy[joystick_index].button[b-1].b !=0;
8595 49874770 }
8596
8597 bool joystick(int32_t s)
8598 {
8599 if(s < 0)
8600 return false;
8601 if (s >= joy[joystick_index].num_sticks)
8602 return false;
8603
8604 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8605 {
8606 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8607 return true;
8608 }
8609 return false;
8610 }
8611
8612 const char* joybtn_name(int32_t b)
8613 {
8614 if (b <= 0 || b > joy[joystick_index].num_buttons)
8615 return "";
8616
8617 return joy[joystick_index].button[b-1].name;
8618 }
8619
8620 const char* joystick_name(int32_t s)
8621 {
8622 if (s < 0 || s >= joy[joystick_index].num_sticks)
8623 return "";
8624
8625 return joy[joystick_index].stick[s].name;
8626 }
8627
8628 int32_t button_pressed()
8629 {
8630 if (joystick_index >= MAX_JOYSTICKS)
8631 return 0;
8632
8633 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8634 {
8635 if(joybtn(i))
8636 return i;
8637 }
8638
8639 return 0;
8640 }
8641
8642 int32_t next_press_key();
8643
8644 int32_t next_joy_input(bool buttons)
8645 {
8646 clear_keybuf();
8647
8648 //first, we need to wait until they're pressing no buttons
8649 for(;;)
8650 {
8651 if(keypressed())
8652 {
8653 switch(readkey()>>8)
8654 {
8655 case KEY_ESC:
8656 return -1;
8657
8658 case KEY_SPACE:
8659 return 0;
8660 }
8661 }
8662
8663 poll_joystick();
8664 bool done = true;
8665
8666 if (buttons)
8667 {
8668 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8669 {
8670 if(joybtn(i)) done = false;
8671 }
8672 }
8673 else
8674 {
8675 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8676 {
8677 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8678 return -2;
8679 }
8680 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8681 {
8682 if(joystick(i)) done = false;
8683 }
8684 }
8685
8686 if(done) break;
8687 rest(1);
8688 }
8689
8690 //now, we need to wait for them to press any button
8691 for(;;)
8692 {
8693 if(keypressed())
8694 {
8695 switch(readkey()>>8)
8696 {
8697 case KEY_ESC:
8698 return -1;
8699
8700 case KEY_SPACE:
8701 return 0;
8702 }
8703 }
8704
8705 poll_joystick();
8706
8707 if (buttons)
8708 {
8709 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8710 {
8711 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8712 return -2;
8713 }
8714 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8715 {
8716 if(joybtn(i))
8717 return i;
8718 }
8719 }
8720 else
8721 {
8722 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8723 {
8724 if(joystick(i))
8725 return i;
8726 }
8727 }
8728 rest(1);
8729 }
8730 }
8731
8732 7412159 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8733 {
8734
2/2
✓ Branch 0 taken 7385874 times.
✓ Branch 1 taken 26285 times.
7412159 bool ret = btn && !flag;
8735 7412159 flag = rawbtn;
8736
8737 7412159 return ret;
8738 }
8739 373393896 static bool rButton(bool &btn, bool &flag)
8740 {
8741
2/2
✓ Branch 0 taken 359632788 times.
✓ Branch 1 taken 13761108 times.
373393896 bool ret = btn && !flag;
8742 373393896 flag = btn;
8743
8744 373393896 return ret;
8745 }
8746 4576884 static bool rButtonPeek(bool btn, bool flag)
8747 {
8748
2/2
✓ Branch 0 taken 4236611 times.
✓ Branch 1 taken 340273 times.
4576884 if(!btn)
8749 {
8750 4236611 return false;
8751 }
8752
2/2
✓ Branch 0 taken 33326 times.
✓ Branch 1 taken 306947 times.
340273 else if(!flag)
8753 {
8754 33326 return true;
8755 }
8756
8757 306947 return false;
8758 4576884 }
8759
8760 // Updated only by keyboard/gamepad.
8761 // If in replay mode, this is set directly by the replay system.
8762 // This should never be read from directly - use control_state instead.
8763 bool raw_control_state[ZC_CONTROL_STATES];
8764
8765 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8766 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8767 // lasts until the next call to load_control_state.
8768 bool control_state[ZC_CONTROL_STATES];
8769 bool disable_control[ZC_CONTROL_STATES];
8770 bool drunk_toggle_state[11];
8771 bool disabledKeys[127];
8772 bool KeyInput[127];
8773 bool KeyPress[127];
8774
8775 bool key_current_frame[127];
8776 bool key_previous_frame[127];
8777
8778 static bool key_system[127];
8779 static bool key_system_previous[127];
8780 static bool key_system_press[127];
8781
8782 bool button_press[ZC_CONTROL_STATES];
8783 bool button_hold[ZC_CONTROL_STATES];
8784
8785 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8786 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8787 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8788 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8789 #define STICK_PRECISION 56 //define your own sensitivity
8790
8791 15501511 void load_control_state()
8792 {
8793 15501511 load_control_called_this_frame = true;
8794
8795
2/2
✓ Branch 0 taken 12371879 times.
✓ Branch 1 taken 3129632 times.
15501511 if (replay_version_check(8, 11))
8796 {
8797
2/2
✓ Branch 0 taken 56333376 times.
✓ Branch 1 taken 3129632 times.
59463008 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8798 56333376 down_control_states[i] = raw_control_state[i];
8799 3129632 }
8800
8801
2/2
✓ Branch 0 taken 15501490 times.
✓ Branch 1 taken 21 times.
15501511 if (!replay_is_replaying())
8802 {
8803
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8804
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8805
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8806
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8817
8818
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(num_joysticks != 0)
8819 {
8820 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8821 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8822 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8823 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8824 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8825 }
8826 else
8827 {
8828 21 raw_control_state[14] = false;
8829 21 raw_control_state[15] = false;
8830 21 raw_control_state[16] = false;
8831 21 raw_control_state[17] = false;
8832 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8833 }
8834 21 }
8835
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15501506 times.
15501511 if (replay_is_active())
8836 {
8837
2/2
✓ Branch 0 taken 1211700 times.
✓ Branch 1 taken 14289806 times.
15501506 if (replay_get_version() < 3)
8838 1211700 replay_poll();
8839
4/4
✓ Branch 0 taken 14289785 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12527791 times.
✓ Branch 3 taken 1761994 times.
14289806 else if (replay_is_replaying() && replay_get_version() < 6)
8840 1761994 replay_peek_input();
8841
4/4
✓ Branch 0 taken 12527791 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 9398159 times.
✓ Branch 3 taken 3129632 times.
12527812 else if (replay_is_replaying() && replay_version_check(8, 11))
8842 3129632 replay_peek_input();
8843
2/2
✓ Branch 0 taken 14234994 times.
✓ Branch 1 taken 1266512 times.
15501506 if (replay_get_version() == 8)
8844 1266512 update_keys();
8845 15501506 }
8846
8847 // Some test replay files were made before a serious input bug was fixed, so instead
8848 // of re-doing them or tossing them out, just check for that zplay version.
8849
3/4
✓ Branch 0 taken 15501501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 15379601 times.
15501511 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8850
2/2
✓ Branch 0 taken 279027018 times.
✓ Branch 1 taken 15501501 times.
294528519 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8851 {
8852 279027018 control_state[i] = raw_control_state[i];
8853
4/4
✓ Branch 0 taken 53035164 times.
✓ Branch 1 taken 225991854 times.
✓ Branch 2 taken 2612094 times.
✓ Branch 3 taken 50423070 times.
279027018 if (botched_input && !control_state[i])
8854 50423070 down_control_states[i] = false;
8855 279027018 }
8856 15501501 bool did_bad_cutscene_btn = false;
8857
2/2
✓ Branch 0 taken 15501501 times.
✓ Branch 1 taken 279027018 times.
294528519 for(int q = 0; q < 18; ++q)
8858
4/4
✓ Branch 0 taken 13194989 times.
✓ Branch 1 taken 265832029 times.
✓ Branch 2 taken 13192672 times.
✓ Branch 3 taken 2317 times.
279029335 if(control_state[q] && !active_cutscene.can_button(q))
8859 {
8860 2317 control_state[q] = false;
8861 2317 did_bad_cutscene_btn = true;
8862 2317 }
8863
2/2
✓ Branch 0 taken 15499841 times.
✓ Branch 1 taken 1660 times.
15501501 if(did_bad_cutscene_btn)
8864 1660 active_cutscene.error();
8865
8866 15501501 button_press[0]=rButton(control_state[0],button_hold[0]);
8867 15501501 button_press[1]=rButton(control_state[1],button_hold[1]);
8868 15501501 button_press[2]=rButton(control_state[2],button_hold[2]);
8869 15501501 button_press[3]=rButton(control_state[3],button_hold[3]);
8870 15501501 button_press[4]=rButton(control_state[4],button_hold[4]);
8871 15501501 button_press[5]=rButton(control_state[5],button_hold[5]);
8872 15501501 button_press[6]=rButton(control_state[6],button_hold[6]);
8873 15501501 button_press[7]=rButton(control_state[7],button_hold[7]);
8874 15501501 button_press[8]=rButton(control_state[8],button_hold[8]);
8875 15501501 button_press[9]=rButton(control_state[9],button_hold[9]);
8876 15501501 button_press[10]=rButton(control_state[10],button_hold[10]);
8877 15501501 button_press[11]=rButton(control_state[11],button_hold[11]);
8878 15501501 button_press[12]=rButton(control_state[12],button_hold[12]);
8879 15501501 button_press[13]=rButton(control_state[13],button_hold[13]);
8880 15501501 button_press[14]=rButton(control_state[14],button_hold[14]);
8881 15501501 button_press[15]=rButton(control_state[15],button_hold[15]);
8882 15501501 button_press[16]=rButton(control_state[16],button_hold[16]);
8883 15501501 button_press[17]=rButton(control_state[17],button_hold[17]);
8884 15501501 }
8885
8886 // Returns true if any game key is pressed. This is needed because keypressed()
8887 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8888 77828899 bool zc_key_pressed()
8889 //may also need to use zc_getrawkey
8890 {
8891
7/10
✓ Branch 0 taken 62852623 times.
✓ Branch 1 taken 14976276 times.
✓ Branch 2 taken 14976276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14976276 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12262293 times.
✓ Branch 7 taken 12262293 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4908601 times.
82737500 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8892
4/6
✓ Branch 0 taken 12262293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12262293 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9336140 times.
✓ Branch 5 taken 9336140 times.
12262293 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8893
4/6
✓ Branch 0 taken 9336140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9336140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6186536 times.
✓ Branch 5 taken 6186536 times.
9336140 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8894
4/6
✓ Branch 0 taken 6186536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6186536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5312311 times.
✓ Branch 5 taken 5312311 times.
6186536 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8895
1/2
✓ Branch 0 taken 5312311 times.
✗ Branch 1 not taken.
5312311 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8896
3/4
✓ Branch 0 taken 5126575 times.
✓ Branch 1 taken 185736 times.
✓ Branch 2 taken 5126575 times.
✗ Branch 3 not taken.
5312311 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8897
3/4
✓ Branch 0 taken 4980447 times.
✓ Branch 1 taken 146128 times.
✓ Branch 2 taken 4980447 times.
✗ Branch 3 not taken.
5126575 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8898
3/4
✓ Branch 0 taken 4959577 times.
✓ Branch 1 taken 20870 times.
✓ Branch 2 taken 4959577 times.
✗ Branch 3 not taken.
4980447 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8899
3/4
✓ Branch 0 taken 4933218 times.
✓ Branch 1 taken 26359 times.
✓ Branch 2 taken 4933218 times.
✗ Branch 3 not taken.
4959577 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8900
3/4
✓ Branch 0 taken 4925933 times.
✓ Branch 1 taken 7285 times.
✓ Branch 2 taken 4925933 times.
✗ Branch 3 not taken.
4933218 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8901
3/4
✓ Branch 0 taken 4910543 times.
✓ Branch 1 taken 15390 times.
✓ Branch 2 taken 4910543 times.
✗ Branch 3 not taken.
4925933 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8902
3/4
✓ Branch 0 taken 4908695 times.
✓ Branch 1 taken 1848 times.
✓ Branch 2 taken 4908695 times.
✗ Branch 3 not taken.
4910543 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8903
3/4
✓ Branch 0 taken 4908660 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4908660 times.
✗ Branch 3 not taken.
4908695 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8904
2/2
✓ Branch 0 taken 4908601 times.
✓ Branch 1 taken 59 times.
4908660 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8905 139114858 return true;
8906
8907 4908601 return false;
8908 18318213 }
8909
8910 294735716 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8911 {
8912 294735716 bool ret = false, drunkstate = false, rawret = false;;
8913 294735716 bool* flag = &down_control_states[btn];
8914
2/7
✓ Branch 0 taken 276398700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18337016 times.
294735716 switch(btn)
8915 {
8916 case btnF12:
8917 ret = zc_getkey(KEY_F12, ignoreDisable);
8918 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8919 eatEntirely = false;
8920 break;
8921 case btnF11:
8922 ret = zc_getkey(KEY_F11, ignoreDisable);
8923 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8924 eatEntirely = false;
8925 break;
8926 case btnF5:
8927 ret = zc_getkey(KEY_F5, ignoreDisable);
8928 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8929 eatEntirely = false;
8930 break;
8931 case btnQ:
8932 ret = zc_getkey(KEY_Q, ignoreDisable);
8933 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8934 eatEntirely = false;
8935 break;
8936 case btnI:
8937 ret = zc_getkey(KEY_I, ignoreDisable);
8938 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8939 eatEntirely = false;
8940 break;
8941 case btnM:
8942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18337016 times.
18337016 if(FFCore.kb_typing_mode) return false;
8943 18337016 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8944 18337016 eatEntirely = false;
8945 18337016 break;
8946 default: //control_state[] index
8947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276398700 times.
276398700 if(FFCore.kb_typing_mode) return false;
8948
6/6
✓ Branch 0 taken 275034470 times.
✓ Branch 1 taken 1364230 times.
✓ Branch 2 taken 16868316 times.
✓ Branch 3 taken 258166154 times.
✓ Branch 4 taken 16868163 times.
✓ Branch 5 taken 153 times.
276398700 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8949
2/2
✓ Branch 0 taken 15732634 times.
✓ Branch 1 taken 260665913 times.
276398547 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8950
4/4
✓ Branch 0 taken 245613475 times.
✓ Branch 1 taken 30785225 times.
✓ Branch 2 taken 5480 times.
✓ Branch 3 taken 30779745 times.
307183925 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8951 276398700 rawret = raw_control_state[btn];
8952 276398700 }
8953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294735716 times.
294735716 assert(flag);
8954
2/2
✓ Branch 0 taken 188379795 times.
✓ Branch 1 taken 106355921 times.
294735716 if(press)
8955 {
8956
2/2
✓ Branch 0 taken 4576884 times.
✓ Branch 1 taken 101779037 times.
106355921 if(peek)
8957 4576884 ret = rButtonPeek(ret, *flag);
8958
2/2
✓ Branch 0 taken 94366878 times.
✓ Branch 1 taken 7412159 times.
101779037 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8959 7412159 else ret = rButton(ret, *flag, rawret);
8960 106355921 }
8961
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 294735716 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
294735716 if(eatEntirely && ret) control_state[btn] = false;
8962
4/4
✓ Branch 0 taken 220225165 times.
✓ Branch 1 taken 74510551 times.
✓ Branch 2 taken 220225084 times.
✓ Branch 3 taken 81 times.
294735716 if(drunk && drunkstate) ret = !ret;
8963 294735716 return ret;
8964 294735716 }
8965
8966 14809037 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8967 {
8968 14809037 byte ret = 0;
8969
2/2
✓ Branch 0 taken 10454744 times.
✓ Branch 1 taken 4354293 times.
14809037 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8970
2/2
✓ Branch 0 taken 14602130 times.
✓ Branch 1 taken 206907 times.
14809037 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8971
2/2
✓ Branch 0 taken 14602255 times.
✓ Branch 1 taken 206782 times.
14809037 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8972
2/2
✓ Branch 0 taken 14602255 times.
✓ Branch 1 taken 206782 times.
14809037 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8973
2/2
✓ Branch 0 taken 14602255 times.
✓ Branch 1 taken 206782 times.
14809037 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8974
2/2
✓ Branch 0 taken 14602255 times.
✓ Branch 1 taken 206782 times.
14809037 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8975
2/2
✓ Branch 0 taken 14602255 times.
✓ Branch 1 taken 206782 times.
14809037 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8976
2/2
✓ Branch 0 taken 14602140 times.
✓ Branch 1 taken 206897 times.
14809037 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8977 14809037 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8978 }
8979
8980 7515 byte checkIntBtnVal(byte intbtn, byte vals)
8981 {
8982 7515 return intbtn&vals;
8983 }
8984
8985 3709070 bool Up()
8986 {
8987 3709070 return getInput(btnUp);
8988 }
8989 727485 bool Down()
8990 {
8991 727485 return getInput(btnDown);
8992 }
8993 981217 bool Left()
8994 {
8995 981217 return getInput(btnLeft);
8996 }
8997 1042828 bool Right()
8998 {
8999 1042828 return getInput(btnRight);
9000 }
9001 532139 bool cAbtn()
9002 {
9003 532139 return getInput(btnA);
9004 }
9005 3306978 bool cBbtn()
9006 {
9007 3306978 return getInput(btnB);
9008 }
9009 bool cSbtn()
9010 {
9011 return getInput(btnS);
9012 }
9013 208608 bool cLbtn()
9014 {
9015 208608 return getInput(btnL);
9016 }
9017 208608 bool cRbtn()
9018 {
9019 208608 return getInput(btnR);
9020 }
9021 bool cPbtn()
9022 {
9023 return getInput(btnP);
9024 }
9025 bool cEx1btn()
9026 {
9027 return getInput(btnEx1);
9028 }
9029 bool cEx2btn()
9030 {
9031 return getInput(btnEx2);
9032 }
9033 bool cEx3btn()
9034 {
9035 return getInput(btnEx3);
9036 }
9037 bool cEx4btn()
9038 {
9039 return getInput(btnEx4);
9040 }
9041 bool AxisUp()
9042 {
9043 return getInput(btnAxisUp);
9044 }
9045 bool AxisDown()
9046 {
9047 return getInput(btnAxisDown);
9048 }
9049 bool AxisLeft()
9050 {
9051 return getInput(btnAxisLeft);
9052 }
9053 bool AxisRight()
9054 {
9055 return getInput(btnAxisRight);
9056 }
9057
9058 bool cMbtn()
9059 {
9060 return getInput(btnM);
9061 }
9062 bool cF12()
9063 {
9064 return getInput(btnF12);
9065 }
9066 bool cF11()
9067 {
9068 return getInput(btnF11);
9069 }
9070 bool cF5()
9071 {
9072 return getInput(btnF5);
9073 }
9074 bool cQ()
9075 {
9076 return getInput(btnQ);
9077 }
9078 bool cI()
9079 {
9080 return getInput(btnI);
9081 }
9082
9083 208304 bool rUp()
9084 {
9085 208304 return getInput(btnUp, true);
9086 }
9087 208096 bool rDown()
9088 {
9089 208096 return getInput(btnDown, true);
9090 }
9091 207900 bool rLeft()
9092 {
9093 207900 return getInput(btnLeft, true);
9094 }
9095 207171 bool rRight()
9096 {
9097 207171 return getInput(btnRight, true);
9098 }
9099 6570 bool rAbtn()
9100 {
9101 6570 return getInput(btnA, true);
9102 }
9103 4619 bool rBbtn()
9104 {
9105 4619 return getInput(btnB, true);
9106 }
9107 14371819 bool rSbtn()
9108 {
9109 14371819 return getInput(btnS, true);
9110 }
9111 18318213 bool rMbtn()
9112 {
9113 18318213 return getInput(btnM, true);
9114 }
9115 185250 bool rLbtn()
9116 {
9117 185250 return getInput(btnL, true);
9118 }
9119 185245 bool rRbtn()
9120 {
9121 185245 return getInput(btnR, true);
9122 }
9123 14372551 bool rPbtn()
9124 {
9125 14372551 return getInput(btnP, true);
9126 }
9127 bool rEx1btn()
9128 {
9129 return getInput(btnEx1, true);
9130 }
9131 bool rEx2btn()
9132 {
9133 return getInput(btnEx2, true);
9134 }
9135 195896 bool rEx3btn()
9136 {
9137 195896 return getInput(btnEx3, true);
9138 }
9139 195896 bool rEx4btn()
9140 {
9141 195896 return getInput(btnEx4, true);
9142 }
9143 bool rAxisUp()
9144 {
9145 return getInput(btnAxisUp, true);
9146 }
9147 bool rAxisDown()
9148 {
9149 return getInput(btnAxisDown, true);
9150 }
9151 bool rAxisLeft()
9152 {
9153 return getInput(btnAxisLeft, true);
9154 }
9155 bool rAxisRight()
9156 {
9157 return getInput(btnAxisRight, true);
9158 }
9159
9160 bool rF11()
9161 {
9162 return getInput(btnF11, true);
9163 }
9164 bool rQ()
9165 {
9166 return getInput(btnQ, true);
9167 }
9168 bool rI()
9169 {
9170 return getInput(btnI, true);
9171 }
9172
9173 36598948 bool DrunkUp()
9174 {
9175 36598948 return getInput(btnUp, false, true);
9176 }
9177 33400695 bool DrunkDown()
9178 {
9179 33400695 return getInput(btnDown, false, true);
9180 }
9181 19586814 bool DrunkLeft()
9182 {
9183 19586814 return getInput(btnLeft, false, true);
9184 }
9185 16665026 bool DrunkRight()
9186 {
9187 16665026 return getInput(btnRight, false, true);
9188 }
9189 15775706 bool DrunkcAbtn()
9190 {
9191 15775706 return getInput(btnA, false, true);
9192 }
9193 15217226 bool DrunkcBbtn()
9194 {
9195 15217226 return getInput(btnB, false, true);
9196 }
9197 14163760 bool DrunkcEx1btn()
9198 {
9199 14163760 return getInput(btnEx1, false, true);
9200 }
9201 14162392 bool DrunkcEx2btn()
9202 {
9203 14162392 return getInput(btnEx2, false, true);
9204 }
9205 bool DrunkcSbtn()
9206 {
9207 return getInput(btnS, false, true);
9208 }
9209 bool DrunkcMbtn()
9210 {
9211 return getInput(btnM, false, true);
9212 }
9213 bool DrunkcLbtn()
9214 {
9215 return getInput(btnL, false, true);
9216 }
9217 bool DrunkcRbtn()
9218 {
9219 return getInput(btnR, false, true);
9220 }
9221 bool DrunkcPbtn()
9222 {
9223 return getInput(btnP, false, true);
9224 }
9225
9226 bool DrunkrUp()
9227 {
9228 return getInput(btnUp, true, true);
9229 }
9230 bool DrunkrDown()
9231 {
9232 return getInput(btnDown, true, true);
9233 }
9234 bool DrunkrLeft()
9235 {
9236 return getInput(btnLeft, true, true);
9237 }
9238 bool DrunkrRight()
9239 {
9240 return getInput(btnRight, true, true);
9241 }
9242 11836904 bool DrunkrAbtn()
9243 {
9244 11836904 return getInput(btnA, true, true);
9245 }
9246 11865491 bool DrunkrBbtn()
9247 {
9248 11865491 return getInput(btnB, true, true);
9249 }
9250 501759 bool DrunkrEx1btn()
9251 {
9252 501759 return getInput(btnEx1, true, true);
9253 }
9254 501580 bool DrunkrEx2btn()
9255 {
9256 501580 return getInput(btnEx2, true, true);
9257 }
9258 bool DrunkrEx3btn()
9259 {
9260 return getInput(btnEx3, true, true);
9261 }
9262 bool DrunkrEx4btn()
9263 {
9264 return getInput(btnEx4, true, true);
9265 }
9266 bool DrunkrSbtn()
9267 {
9268 return getInput(btnS, true, true);
9269 }
9270 bool DrunkrMbtn()
9271 {
9272 return getInput(btnM, true, true);
9273 }
9274 12901461 bool DrunkrLbtn()
9275 {
9276 12901461 return getInput(btnL, true, true);
9277 }
9278 12896156 bool DrunkrRbtn()
9279 {
9280 12896156 return getInput(btnR, true, true);
9281 }
9282 bool DrunkrPbtn()
9283 {
9284 return getInput(btnP, true, true);
9285 }
9286
9287 18803 void eat_buttons()
9288 {
9289 18803 getInput(btnA, true, false, true);
9290 18803 getInput(btnB, true, false, true);
9291 18803 getInput(btnS, true, false, true);
9292 18803 getInput(btnM, true, false, true);
9293 18803 getInput(btnL, true, false, true);
9294 18803 getInput(btnR, true, false, true);
9295 18803 getInput(btnP, true, false, true);
9296 18803 getInput(btnEx1, true, false, true);
9297 18803 getInput(btnEx2, true, false, true);
9298 18803 getInput(btnEx3, true, false, true);
9299 18803 getInput(btnEx4, true, false, true);
9300 18803 }
9301
9302 // Is true for the _first frame_ of a key press.
9303 // But! it is possible that a script manually sets the value of KeyPress,
9304 // in which case it will be restored to the "true" value based on `key_current_frame`
9305 // and `key_previous_frame` on the next frame.
9306 61 bool zc_readkey(int32_t k, bool ignoreDisable)
9307 {
9308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(ignoreDisable) return KeyPress[k];
9309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 switch(k)
9310 {
9311 case KEY_F7:
9312 case KEY_F8:
9313 case KEY_F9:
9314 return KeyPress[k];
9315
9316 default:
9317
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 15 times.
61 return KeyPress[k] && !disabledKeys[k];
9318 }
9319 61 }
9320
9321 // Is true for _every frame_ a key is held down.
9322 // But! it is possible that a script manually sets the value of KeyInput,
9323 // in which case it will be restored to the "true" value based on `key_current_frame`
9324 // on the next frame.
9325 bool zc_getkey(int32_t k, bool ignoreDisable)
9326 {
9327 if(ignoreDisable) return KeyInput[k];
9328 switch(k)
9329 {
9330 case KEY_F7:
9331 case KEY_F8:
9332 case KEY_F9:
9333 return KeyInput[k];
9334
9335 default:
9336 return KeyInput[k] && !disabledKeys[k];
9337 }
9338 }
9339
9340 // Reads (and then clears) the current frame key state directly.
9341 // Scripts can also modify `key_current_frame`.
9342 933 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9343 {
9344
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 931 times.
933 if(zc_getrawkey(k, ignoreDisable))
9345 {
9346 2 _key[k]=key[k]=key_current_frame[k]=0;
9347 2 return true;
9348 }
9349 931 _key[k]=key[k]=key_current_frame[k]=0;
9350 931 return false;
9351 933 }
9352
9353 // Reads the current frame key state directly.
9354 // Scripts can also modify `key_current_frame`.
9355 124383660 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9356 {
9357
2/2
✓ Branch 0 taken 106065325 times.
✓ Branch 1 taken 18318335 times.
124383660 if(ignoreDisable) return key_current_frame[k];
9358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318335 times.
18318335 switch(k)
9359 {
9360 case KEY_F7:
9361 case KEY_F8:
9362 case KEY_F9:
9363 return key_current_frame[k];
9364
9365 default:
9366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18318335 times.
18318335 return key_current_frame[k] && !disabledKeys[k];
9367 }
9368 124383660 }
9369
9370 // Only used for a handful of keys, like tilde and Function keys.
9371 // This state is never read within the game.
9372 // It exists so that all keyboard input still functions during replay,
9373 // without inadvertently doing things like toggling throttling if the player
9374 // presses ~
9375 18340655 bool zc_get_system_key(int32_t k)
9376 {
9377 18340655 return key_system[k];
9378 }
9379
9380 // True for the _first_ frame of a key press.
9381 164863917 bool zc_read_system_key(int32_t k)
9382 {
9383 164863917 return key_system_press[k];
9384 }
9385
9386 2326413051 bool is_system_key(int32_t k)
9387 {
9388
2/2
✓ Branch 0 taken 2161549134 times.
✓ Branch 1 taken 164863917 times.
2326413051 switch (k)
9389 {
9390 case KEY_BACKQUOTE:
9391 case KEY_CLOSEBRACE:
9392 case KEY_END:
9393 case KEY_HOME:
9394 case KEY_OPENBRACE:
9395 case KEY_PGDN:
9396 case KEY_PGUP:
9397 case KEY_TAB:
9398 case KEY_TILDE:
9399 164863917 return true;
9400 }
9401 2161549134 return is_Fkey(k);
9402 2326413051 }
9403
9404 18318213 void update_system_keys()
9405 {
9406
2/2
✓ Branch 0 taken 2326413051 times.
✓ Branch 1 taken 18318213 times.
2344731264 for (int32_t q = 0; q < 127; ++q)
9407 {
9408
2/2
✓ Branch 0 taken 384682473 times.
✓ Branch 1 taken 1941730578 times.
2326413051 if (!is_system_key(q))
9409 1941730578 continue;
9410
9411 384682473 key_system[q] = key[q];
9412
1/2
✓ Branch 0 taken 384682473 times.
✗ Branch 1 not taken.
384682473 key_system_press[q] = key_system[q] && !key_system_previous[q];
9413 384682473 key_system_previous[q] = key_system[q];
9414 384682473 }
9415 18318213 }
9416
9417 19584725 void update_keys()
9418 {
9419
2/2
✓ Branch 0 taken 2487260075 times.
✓ Branch 1 taken 19584725 times.
2506844800 for (int32_t q = 0; q < 127; ++q)
9420 {
9421 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9422
2/2
✓ Branch 0 taken 2487247375 times.
✓ Branch 1 taken 12700 times.
2487260075 if (!replay_is_replaying())
9423 12700 key_current_frame[q] = key[q];
9424
9425
2/2
✓ Branch 0 taken 2468162833 times.
✓ Branch 1 taken 19097242 times.
2487260075 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9426 2487260075 KeyInput[q] = key_current_frame[q];
9427 2487260075 key_previous_frame[q] = key_current_frame[q];
9428 2487260075 }
9429 19584725 }
9430
9431 bool zc_disablekey(int32_t k, bool val)
9432 {
9433 switch(k)
9434 {
9435 case KEY_F7:
9436 case KEY_F8:
9437 case KEY_F9:
9438 return false;
9439
9440 default:
9441 disabledKeys[k] = val;
9442 return true;
9443 }
9444 }
9445
9446 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9447 {
9448 timer=timer;
9449 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9450 }
9451